Python Selenium Control - Inability to Use "Expectations"

We support the library used by test scripts that conduct system-level testing. Part of the system under test is a website, and for navigation and interaction with the website we use JPype to manage the Selenium 2.0 web server. Selenium 2.0 has a Java and C # interface, and so far we cannot rewrite the test library using Java or C #, so we use JPype to control it. This system was built by someone who recently left the company, and now I'm starting to work on it.

Whenever we interact with a website, we use time.sleeps:

self.browserDict['Driver'].findElement(self.browserDict['By'].id(byId)).click() time.sleep(_AJAX_TIMEOUT) >>> self.browserDict['Driver'] <jpype._jclass.org.openqa.selenium.firefox.FirefoxDriver object at 0x0626DD30> >>> byId 'login_submit' 

At any time, when we do not click anything, there is a time.sleep () function to wait for the next page to load. We have a lot of AJAX, but it looks like I have to wait for AJAX to finish loading. Before he left, the author of this tool explained that there was a problem with JPype or Selenium that was preventing it. So far I can’t find this problem, but I also don’t know the wait command that will be used here.

Edit:
One option is to use implicitlyWait , based on the assumption that if the timeout is 6 seconds, it will return immediately after the item is found, however it seems to always wait a full 6 seconds when the page loads.

Edit2: Python binding directly to selenium 2.0 is now missing, however, there seems to be no way to wait for Ajax to load with this library: time.sleep(0.2) # Let the page load, will be added to the AP (from their example).

+4
source share
2 answers

ImplicitlyWait via JPype and Java bindings works and can fulfill the need here.

0
source

Perhaps http://wiki.openqa.org/display/SEL/waitForCondition can satisfy your criteria?

0
source

All Articles