Ruby Webdriver-related Operations Guide _ruby topics

Source: Internet
Author: User

Dominant wait:

wait = selenium::webdriver::wait.new (: Timeout => 3)
Wait.until {driver.find_element (: id => "cheese"). Displayed? }

Hidden wait:

Driver = Selenium::webdriver.for:firefox
driver.manage.timeouts.implicit_wait = 3 # seconds

Internal timeout:

Webdriver uses the HTTP protocol internally to interact with various driver. By default, the Net::http protocol in the Ruby Standard library uses a default timeout of 60 seconds, and if you call driver to load a page for more than 60 seconds, you will see a timeout error from net:http. You can manually configure the timeout time before starting the browser.


Client = selenium::webdriver::remote::http::D efault.new
client.timeout = # seconds
Driver = Selenium:: Webdriver.for (: Remote,: http_client => client)

When Ruby Webdriver starts the Firefox driver, load the firebug extension

See on the official Wiki
Adding an extension
It ' s often useful to have Firebug available in the Firefox instance launched by Webdriver:

Profile = Selenium::webdriver::firefox::P rofile.new
profile.add_extension ("/path/to/firebug.xpi")
driver = Selenium::webdriver.for:firefox,:p rofile => profile

So I tried it, but every time I was prompted to firebug.xpi I couldn't find it.

We got a free day today, the problem is solved.
In fact, the previous understanding is wrong, because Dr =selenium::webdriver.for:ff
When you start FF, you initialize one of the simplest profile, which contains no firebug plug-ins, that is, even if we originally installed Firebug on Firefox, it will not start, so when we need to use Firebug, To load a firebug extension

Profile.add_extension ("/path/to/firebug.xpi")

As for "/path/to/firebug.xpi" is FIREBUG.XPI's storage path, we can go online to download a firebug.xpi (corresponding version, my FF is 14, You can use FIREBUG-1.10.4.XPI, preferably a non-firefox browser download, or you will be prompted to install directly to Firefox)
We can store the FIREFOX.XPI directly in the path our script holds, and the relative and absolute paths can be
Give a example of Baidu

Require ' selenium-webdriver '
 
#dr = selenium::webdriver.for:ff Profile
= Selenium::webdriver::firefox:: Profile.new
profile.add_extension ("Path/to/firebug-1.10.4.xpi") <font color= "DarkOrchid" ># FIREFOX-1.10.4.XPI is stored under path/to of the script sibling </font>
dr = Selenium::webdriver.for:firefox,:p rofile => profile
dr.get "Http://www.baidu.com"

This way when we need to look at the DOM structure, we can debug it directly on the Open test page without having to open a new Firefox to look at the DOM structure.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.