6
Traceback (most recent call last):
  File "Inventorytest.py", line 88, in <module>
    j.go_to_application()
  File "Inventorytest.py", line 65, in go_to_application
    EC.element_to_be_clickable((By.ID, 'FavoriteApp_ITEM'))
  File "/home/naroladev/Mercury_Back-End/mercuryenv/lib/python3.6/site-packages/selenium/webdriver/support/wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

I got above exception with EC2 server instance. My script works absolutely fine with Ubuntu and Mac os with any version of firefox and geckodriver on local system. But got above error with EC2 ubuntu 18.04.01 version, in this I have also tried upgrade and downgrade firefox and geckodriver versions but still not work. Can anyone help me out with suggestion and solutions.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
VISHAL LIMGIRE
  • 529
  • 1
  • 5
  • 21
  • Are you sure that the application is launched and navigated to the page where you have the element with id `FavoriteApp_ITEM`? – supputuri Jul 21 '20 at 12:38
  • Yes sure it working fine with local ubuntu and mac os but on EC2 getting issue there also I have tried upgrade and downgrade firefox and gecko driver not work for me – VISHAL LIMGIRE Jul 21 '20 at 12:40
  • Meaning, the firefox instance is not launched when you ran the script in EC2? – supputuri Jul 21 '20 at 12:41
  • Initially, login is working FavoriteApp_ITEM not working here got an issue and also one weird thing on EC2 server when running python script on debugging mode it's working absolutely fine – VISHAL LIMGIRE Jul 21 '20 at 12:44
  • The initial phase of script work but it stuck with ```FavoriteApp_ITEM``` gets above issue on server – VISHAL LIMGIRE Jul 21 '20 at 13:17

1 Answers1

3

This error message...

Traceback (most recent call last):
  File "Inventorytest.py", line 88, in <module>
    j.go_to_application()
  File "Inventorytest.py", line 65, in go_to_application
    EC.element_to_be_clickable((By.ID, 'FavoriteApp_ITEM'))
  File "/home/naroladev/Mercury_Back-End/mercuryenv/lib/python3.6/site-packages/selenium/webdriver/support/wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

...implies that the WebDriver variant was unable to locate the desired WebElement within the timeframe for which the WebDriverWait was constructed.


WebDriverWait

The WebDriverWait constructor takes a WebDriver instance as an argument and timeout in seconds.

Hence, irrespective of usage of either of the expected_conditions, WebDriverWait on failure will result in TimeoutException.


This usecase

In this usecase, the line:

EC.element_to_be_clickable((By.ID, 'FavoriteApp_ITEM'))

was unable to identify the desired element within the desired time frame hence you faced TimeoutException.

However, from TimeoutException it will be tough to dig out the actual result of the failure.


Solution

As a solution to know about the exact cause of the failure, you need to remove the WebDriverWait and replace the line of code with either:

  • find_element_by_class_name(name)
  • find_element_by_css_selector(css_selector)
  • find_element_by_id(id)
  • find_element_by_link_text(link_text)
  • find_element_by_name(name)
  • find_element_by_partial_link_text(partial_link_text)
  • find_element_by_tag_name(tag_name)
  • find_element_by_xpath(xpath)

If required you can slow down the search inducing waits through time.sleep(secs) while debugging.


References

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352