Reputation: 44395
I have a very complex and non public selenium script to perform GUI tests. When running the tests locally everything works fine. But when I run the exact same tests inside a docker image (used on jenkins), the tests do not run through. An element is not found in the webpage.
The following is a part where I wait for an input box to appear and to fill in some text:
self._handler.log("B")
elem = WebDriverWait(self._handler.webdriver, 30).\
until(EC.visibility_of_element_located((By.XPATH, "//input[@placeholder='Create new collab']"))) # TIMEOUT
self._handler.log("C")
elem.clear()
self._handler.log("D")
elem.send_keys(collab_name)
I get a timeout error in the WebDriverWait
line.
I save the page source in the log
step (just before the WebDriverWait
line), and see the following part in the html:
<div class="md-tab container-centered" id="create" style="width: 988px; left: 988px;">
<div class="md-input-container md-theme-default md-input-placeholder md-input-focused">
<label>
Collab Name
</label>
<input class="md-input" placeholder="Create new collab" type="text"/>
<!-- -->
<!-- -->
<!-- -->
</div>
So the element is available in the page source, and visible as well (as the following screenshot made at step 'B' reveals):
What is going on? A bug in selenium?
Addendum
What I tried as well is the following chain:
elem = WebDriverWait(self._handler.webdriver, 30).\
until(EC.presence_of_element_located((By.XPATH, "//div[@id='create']//input")))
actions = ActionChains(self._handler.webdriver)
actions.move_to_element(elem)
actions.send_keys(collab_name)
actions.perform()
But in this case the input field is not populated by the text in collab_name
. The input field stays empty.
Upvotes: 2
Views: 974
Reputation: 871
I would suggest to use visibility_of_element_located instead of presence_of_element_located. There is a small difference between both. Altough the element could be present it does not mean that it is also already visible.
That the element is visible on the screenprint means that it was visible at the moment of making this screenprint wich is probably just after the exception occurs.
Upvotes: 2