Tag Archives: selenium

Four ways to solve selenium’s error “element is not clickable at point…”

Click to report an error

When using selenium, click events are triggered, and the following exceptions are often reported:

Element is not clickable at point

Causes and Solutions

There are four reasons

1. Not loaded

Wait for the element to be loaded before proceeding
you can use the python library

import time 
time.sleep(3)

But it’s better to use selenium’s own webdriverwait

from selenium.webdriver.support.ui import WebDriverWait

WebDriverWait(driver, 10).until(EC.title_contains("element"))

For the specific usage of webdriverwait, please click the reference document

2. In iframe

If the element is in the iframe, you can’t find it in the window, and you can’t click it. So, switch to iframe to find the element

driver.switch_to_frame("frameName")  # Switching by frame name
driver.switch_to_frame("frameName.0.child") # child frame
driver.switch_to_default_content() # return

For other related switching, please click the reference document

3. Not in the window, need to pull the scroll bar

The list page of many websites does not return all the contents immediately, but is displayed according to the view. Therefore, we need to drag the scroll bar to display the content to be obtained in the window

page = driver.find_element_by_partial_link_text(u'next page')
driver.execute_script("arguments[0].scrollIntoView(false);", page)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, u'next page'))).click()

About the contents of the drop-down scroll bar, please refer to the blog

4. The element to be clicked is covered

You can use the event chain to solve
problems, such as drop-down menus, which can be displayed through the hover, and then you can click

menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1")

ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()

For details of the event chain, please click document

selenium : WebDriverException: Message: chrome not reachable

A super detailed tutorial: springboot integrates mybatis plus>>>

Error report screenshot

Cause of error

According to the prompt, it was because the chromedriver was not found. Finally, after debugging, there was a problem with the driver in my ‘/ usr/local/bin/chromedriver’, so I downloaded a driver again and decompressed it to my/home/v-gazh/apps Directory:

Then execute the code and you are OK

How to Solve centos7 selenium–unknown error: DevToolsActivePort file doesn’t exist

Unknown error: devtoolsactivport file doesn’t exist

In the morning, there was a problem when starting Chrome with selenium under Linux: error:

Traceback (most recent call last):
  File "get2.py", line 62, in <module>
    browser = webdriver.Chrome()
  File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute
    self.error_handler.check_response(response)
  File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.9.0-6-amd64 x86_64)

Solution: add code:

from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
browser = webdriver.Chrome(chrome_options=chrome_options)

The “– no sandbox” parameter allows chrome to run under the root permission, and the “– headless” parameter allows chrome to have a better experience without opening the graphical interface

The “– no sandbox” parameter allows chrome to run under the root permission, and the “– headless” parameter allows chrome to have a better experience without opening the graphical interface

chrome_options.add_argument('blink-settings=imagesEnabled=false')
chrome_options.add_argument('--disable-gpu')

Unknown error: cannot find chrome binary

Problem Description:

After executing selenium test cases in pcharm, it can run normally

Integrated in Jenkins. When building, it is found that the build is successful. However, when viewing the console output, an error is reported: unknown error: cannot find chrome binary

The reason is that Chrome browser cannot be found and chrome.exe environment variable configuration is missing

Solution:

Configuration build execution status:

1. Back to Jenkins home page, click “build execution status” or “build executor status”, and local information will be listed on the right

2. Click the local settings button to add the directory of chrome.exe in the path

3. Click build now again and the execution is successful

selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to…

Using selenium webriver for the first time, webdriver.Firefox ()

Error report selenium.common.exceptions . webdriverexception: Message: ‘geckodriver’ executable needs to be in path.

Windows processing method:

1. Download geckodriver.exe :

Download address: https://github.com/mozilla/geckodriver/releases
Choose to download according to the system version (such as windows 64 bit system)

2. After downloading and decompressing, the getckodriver.exe Put it in the python installation directory. If you have checked addtopath when installing python, you don’t need to do anything. Otherwise, you need to add the python installation directory to the system variable environment variable path.

3. Run the code again
2

Other browsers have similar processing methods; download address of each browser driver

https://www.seleniumhq.org/about/platforms.jsp#browsers

firefox: https://github.com/mozilla/geckodriver/releases/

chrome: https://code.google.com/p/chromedriver/downloads/list

ie: http://selenium-release.storage.googleapis.com/index.html