0

I am fairly new to selenium and just encountered the following code snippet.

try:
    element_present = EC.presence_of_element_located((By.ID, 'you_wontx_be'))
    WebDriverWait(browser, timeout2).until(element_present)
except TimeoutException:
    pass

I believe the code waits until a certain element is loaded in browser. What does the tuple parameter expect as its first and second element?

Nabin
  • 11,216
  • 8
  • 63
  • 98
  • First is type and second is value. https://stackoverflow.com/questions/34504839/how-do-i-use-seleniums-wait – Aaron Paul Jun 13 '17 at 01:29

2 Answers2

3

Argument of presence_of_element_located function should be a valid locator: tuple object where first coordinate is a type of path (str object, values can be obtained using By class fields, where By is a some sort of enumeration) and the second is the path itself (str object too)

Further reading

Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
0

After some work and experience, I am able to figure out what this is. I am pretty much sure that the first parameter is a selection or locator type. This is usually ID, Class name, XPATH, etc. While the second parameter is the value of either ID, Class name, XPATH. So in my use case as mentioned in question, this you_wontx_be is some ID which is expected to be not present on the page and hence times out each time.

Nabin
  • 11,216
  • 8
  • 63
  • 98