Automation test basics-Selenium browser operations, basics-selenium

Source: Internet
Author: User

Automation test basics-Selenium browser operations, basics-selenium
Selenium mainly provides methods for operating various elements on the page, but it also provides methods for operating the browser itself, such as the browser size, browser back-up, forward button, and so on. I. Control the browser window size. Sometimes we want to open it in a browser size so that the accessed page can run in this size. For example, you can set the browser size to the mobile terminal size (480*800) and then visit the mobile site to evaluate its style. WebDriver provides the set_window_size () method to set the browser size. 2. Set the sleep time. It takes several seconds to load the page after the Baidu website is opened. It is best to wait until the page is loaded before proceeding to the next step. 3. Control the browser's forward and backward. When using the browser to browse the webpage, the browser provides the backward and forward buttons to switch between the browsed webpages conveniently, webDriver also provides the corresponding back () and forward () Methods to simulate the backward and forward buttons. The following example shows how to use these two methods. 4. Page refresh sometimes, after page operations, data may not be synchronized in time and needs to be refreshed again. 5. Page 6. close and exit the browser. Either close or quit. Close is used to close the current window. When many windows are opened, you can close some windows with close. quit is used to end processes and close all windows. Written at the end of the article: these are all compiled into a single word. Originality is not enough. There may be a lot of similar materials, the purpose of this article is to encourage you to develop good habits on the learning road. Therefore, please indicate the source for reprinting. Thank you!

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.