Python django: How to call selenium.set_speed () with django LiveServerTestCase

To run my functional tests, I use LiveServerTestCase .

I want to call set_speed (and other methods, set_speed is just an example) which are not in the webdriver but are in the selenium object.

http://selenium.googlecode.com/git/docs/api/py/selenium/selenium.selenium.html#module-selenium.selenium

my subclass of LiveServerTestCase

 from selenium import webdriver class SeleniumLiveServerTestCase(LiveServerTestCase): @classmethod def setUpClass(cls): cls.driver = webdriver.Firefox() cls.driver.implicitly_wait(7) cls.driver.maximize_window() # how to call selenium.selenium.set_speed() from here? how to get the ref to the selenium object? super(SeleniumLiveServerTestCase, cls).setUpClass() 

How to get it? I can’t name the designer in selenium, I think.

+7
source share
1 answer

Not. Setting speed in WebDriver is not possible, and the reason for this is that you do not need it at all, and the "wait" is now performed at a different level.

Before it was possible to tell Selenium, do not run it at normal speed, run it at a slower speed, to allow more things to be available when loading a page, for pages with slow loading or AJAX pages.

Now you're missing it all. Example:

I have a login page, I am logged in and after logging in I see the message "Welcome". The problem is that the welcome message is not displayed instantly and is on a time delay (using jQuery).

The Pre WebDriver code will detect Selenium, run this test, but slow it down so that we can wait for the greeting to appear.

The new WebDriver code will dictate Selenium, run this test, but when we log in, wait 20 seconds for a welcome message to appear, using an explicit wait.

Now, if you really want to access Selenium β€œset” speed, I would first recommend against it, but the solution would be to plunge into the old, now obsolete code.

If you are already heavily using WebDriver, you can use WebDriverBackedSelenium , which can give you access to old Selenium methods while still supporting WebDriver, so most of your code will remain the same.

https://groups.google.com/forum/#!topic/selenium-users/6E53jIIT0TE

The second option is to dive into the old Selenium code and use it, it will greatly change your existing code (because it was before the concept of WebDriver).

The code for Selenium RC and WebDriverBackedSelenium lives here for the curious:

https://code.google.com/p/selenium/source/browse/py/selenium/selenium.py

Something along the lines of:

 from selenium import webdriver from selenium import selenium driver = webdriver.Firefox() sel = selenium('localhost', 4444, '*webdriver', 'http://www.google.com') sel.start(driver = driver) 

Then you will access this:

 sel.setSpeed(5000) 
+7
source

All Articles