I'm trying to click an options from a website dropdown menu but I am not able to click.

I am using "xpath" locators for the element and I upgraded my chrome to the latest version for chromedriver.

I am using:

  • chrome=68.0.3440.106
  • chromedriver=2.41.578700
  • platform=Linux 4.15.0-30

Code snippet that contains error line:

    def test_adsz(self):
    driver = self.driver
    driver.find_element_by_xpath(u"(//a[contains(text(),'ÜYE GİRİŞİ')])[2]").click()
    driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='alın'])[1]/following::button[1]").click()
    driver.find_element_by_xpath("//img[@alt='User Name']").click()
    driver.find_element_by_link_text(u"Üye Listesi").click()
    driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='Tanım İşlemleri'])[1]/following::span[1]").click()
    driver.find_element_by_xpath(u"(//a[contains(text(),'Çıkış Yap')])[2]").click()  

My error line:


My traceback info:

traceback (most recent call last):
File "/usr/local/lib/python2.7/dist- 
packages/selenium/webdriver/remote/webelement.py", line 80, in click
File "/usr/local/lib/python2.7/dist- 
packages/selenium/webdriver/remote/webelement.py", line 628, in 
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist- 
packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
File "/usr/local/lib/python2.7/dist- 
packages/selenium/webdriver/remote/errorhandler.py", line 242, in 
raise exception_class(message, screen, stacktrace)
ElementNotVisibleException: Message: element not visible`

Thanks in advance.

  • sqa.stackexchange.com/questions/33880/… or stackoverflow.com/questions/27927964/… may be related / help you
    – dvniel
    Aug 15, 2018 at 8:44
  • share some code that produces the issue.
    – Alexey R.
    Aug 15, 2018 at 9:23
  • I've added the code snippet and the error line. @AlexeyR. Aug 15, 2018 at 10:47
  • but due to the error you have posted, your error line is driver.find_element_by_xpath(u"(//a[contains(text(),'1. Sınıf')]) [2]").click() however you mention line driver.find_element_by_xpath(u"(//a[contains(text(),'Sınıf')])[2]").click(). So eventually which line does produce the error?
    – Alexey R.
    Aug 15, 2018 at 11:10
  • I edited traceback info area. Error line is driver.find_element_by_xpath(u"(//a[contains(text(),'Sınıf')])[2]").click() @AlexeyR. Aug 15, 2018 at 11:17

1 Answer 1


You should find the reason why the element is not visible at that point. Is the element marked as display:none or hidden by a hide element class? Or maybe is it not visible because there's some other element on top of it or out of visible page borders?

Anyway for the first case where it is somehow marked as hidden you should make it visible. This can be done with javascript. Try this method before clicking on your element:

JavascriptExecutor js = (JavascriptExecutor) driver;

You can also use


but i find "initial" work more efficiently most of the time. You may need to perform this action to the parent element if this is the one being hidden.

In the second case you should probably use something like this before click:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView(true);" + "window.scrollBy(0,-100);", element);

The "window.scrollBy(0,-100);" is mandatory argument for firefox browser but optional for chrome.

  • Thank you @gmitsios but I am using selenium with Python not Java. Aug 28, 2018 at 7:13
  • Ok use driver.execute_script(javascript code here) then instead of js.executeScript(). The rest is javascript which remains the same.
    – gmitsios
    Aug 28, 2018 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.