What are the common driver methods that can be applied to browsers in Selenium with python?

Automation TestingSelenium Web DriverSoftware Testing

<p style="">There are multiple common web driver methods that allow operation on browsers in Selenium with Python. Some of these methods are listed below &minus;</p><ul class="list"><li><p><strong>driver.get(url)</strong></p><p>This method is used to navigate or launch a new URL. The webdriver waits until there is full page load. For an application that has AJAX code, the web driver remains unaware about complete loading of the page. Thus for these situations we need to use waits.</p></li><li><p><strong>driver.maximize_window()</strong></p><p>This method is used to maximize the active window that is interacting with the web driver.</p></li><li><p><strong>driver.minimize_window()</strong></p><p>This method is used to minimize the active window that is interacting with the web driver.</p></li><li><p><strong>driver.back()</strong></p><p>This method is used to move to a single step back in the history of browsers.</p></li><li><p><strong>driver.forward()</strong></p><p>This method is used to move to a single step forward in the history of browsers.</p></li><li><p><strong>driver.refresh()</strong></p><p>This method is used to refresh the current page.</p></li></ul><h2>Example</h2><p>Code Implementation with browser methods.</p><pre class="prettyprint notranslate">from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke #actual browser driver = webdriver.Chrome(executable_path=&quot;C:\\chromedriver.exe&quot;) # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get(&quot;https://www.tutorialspoint.com/about/about_careers.htm&quot;) #to maximize the browser driver.maximize_window() #to refresh the browser driver.refresh() #get method to launch another URL driver.get(&quot;https://www.tutorialspoint.com/index.htm&quot;) #to minimize the browser driver.minimize_window() #to move one step back in browser history driver.back() #to move one step forward in browser history driver.forward() #to close the browser driver.close()</pre>
Updated on 29-Jul-2020 09:29:22