PHPUnit Selenium, clickAndWait() function doesn't work in Opera PHPUnit Selenium, clickAndWait() function doesn't work in Opera selenium selenium

PHPUnit Selenium, clickAndWait() function doesn't work in Opera


I was having this issue in FF as well, this was the solution that I came up with:

def wait_for_element_by_id(eid):   "Wait for an element to be present"   element = WebDriverWait(driver, 10).until(       EC.presence_of_element_located((By.ID, eid))   )   return []


There wasn't enough information in the original post to suggest a definitive solution, but tying in with the comment @Andre provided, the "sanitizing" browsers do, and in turn provide in functions such as "Copy xPath" can be very misleading, and lead to many problems during testing, depending on the structure of the xPath.

For example:

<html>    <head></head>    <body>        <div>            <table>                <tr>                    <td>test</td>                </tr>                <tr>                    <td>value</td>                </tr>            </table>        </div>    </body></html>

While the above code is very minimal, browsers will report the xPath of test as one of the following:

  • /html/body/div/table/tr/td ( which in many cases will return you both test and value )
  • /html/body/div/table/tr[1]/td[1] ( a more precise match to just test )
  • /html/body/div/table/tbody/tr/td ( notice the added tbody )

And so on. Obviously, you don't run into this problem with a more unique identifier available ( IE an id -> //*[@id="someElement"] ), but in many projects we've taken over, where the unit tests were originally only done on one browser, we've seen errors similar to the one reported, and it turned out the "sanitizing" browsers do create one of two problems:

  • The path was retrieved on a browser that "sanitized", and then run on a browser that wouldn't and couldn't find the element.
  • The path was retrieved on a browser that wasn't "sanitized", and then run on a browser that does sanitize.

Both issues resulting in a non-match.


I had similar problem and, unfortunately, only solution I came up with was... adding 'sleep'. Ugly, but works.