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!