Speeding up Selenium Webdriver

2020-08-21 04:38发布

问题:

I am using Selenium Webdriver (2.0) under the Perl language bindings, with Firefox 20. It is incredibly slow. For example, one common operation is to fill in a couple of <input type="text"> fields with an ID and password. I could type it in 2 to 3 times faster than Selenium does a 'send_keys' method. Locating elements, such as a table cell with specific text in a large table, is like watching paint dry.

I thought that maybe there is some sort of default speed setting that wasn't at its highest value, but the get_speed and set_speed methods have been removed. So, is Selenium already running flat out, or is there some setting I can tweak? I've seen many questions about how to slow down Selenium, but at this time I'm looking for how to speed it up. I'll worry about slowing it down later, if necessary.

  • Perl: Strawberry Perl 5.16.3 (driver for test program)
  • Java: 1.7.0_21-b11 (for the Selenium Server .jar file) (32 bit)
  • Selenium::Remote::Driver: 0.16 via CPAN (Perl language bindings)
  • Selenium-Server-Standalone: 2.32.0
  • OS: Windows 7 Professional, SP 1 (64 bit)
  • hardware: Dell Precision T1650 (Xeon 3.5GHz 16GB RAM)
  • browser: Firefox 20.0.1 with Selenium IDE 1.10.0 (production users will have Chrome, IE9, Opera)

Since even an "atomic" operation such as entering text into an input field is so slow, I don't think it's an issue with using XPath locators rather than CSS, or Perl instead of some other language. It's been suggested that I try Chrome instead of FF -- can it help that much? I do a lot of locating text within table cells, so CSS locators are unfortunately of limited value.

Thanks much for any help on this! I'm going to look real bad if this test automation isn't faster than manually running the tests!

回答1:

A bit late to the party but there is the phantom driver http://phantomjs.org/ which doesn't use a screen driver and can be hooked into selenium.

  ./phantomjs --webdriver=5556 --webdriver-selenium-grid-hub=http://localhost:4444

Or link it to a remote hub



回答2:

This may not be directly applicable, but you can follow a few simple tips to first investigate where most of the time is spent. Look at the article below:

https://blog.mavenhive.in/7-tips-to-speed-up-your-webdriver-tests-4f4d043ad581

I guess most of these are generic steps which would apply irrespective of the tool used for testing too.