Selenium Webdriver C Tutorial

Sep 14, 2018  In this video we will discuss Selenium WebDriver with C#. Selenium is one of the most popular automation tool in market. Selenium with C# also has high demand in market so let's discuss Step.

Selenium WebDriver is one of the most popular tools for Web UI Automation. And no better than Python can complement it to automate a broad range of web applications. Hence, we brought this Selenium Webdriver Python tutorial to ramp you up quickly on the task. So let’s start by understanding what all we have to do in UI automation testing.

Web UI Automation means the automatic execution of the actions performed in a web browser window like navigating to a website, filling forms that include dealing with text boxes, radio buttons and drop downs, submitting the forms, browsing through web pages, handling pop-ups and so on. Selenium WebDriver is the one that can automate all these tasks. It can interact with all types of Web browsers available till date like Firefox, Internet Explorer, Safari, and Chrome, etc.

Most of the time, we use Java and Eclipse to create a Selenium Webdriver project. In this post, we’ll use Python to replace Java and demonstrate how the Selenium Webdriver Python integration works to achieve Web UI automation.

  1. In this tutorial, we will discuss working with Selenium in C# along with Visual Studio IDE. NUnit is the Unit Testing framework supported by Visual Studio and Selenium WebDriver.
  2. In this series, we will discuss working with selenium in c# along with visual studio ide. Selenium with c# is yet another language binding of selenium webdriver, but most popularly used like java.
  3. Jan 20, 2016. In 2006, Selenium WebDriver was launched at Google. In 2008, the whole Selenium team decided to merge Selenium WebDriver with Selenium RC in order to form more powerful tool called.
  4. Here is a set of Selenium C# tutorial. These tutorials starts from Beginner level of Selenium in CSharp and move towards the Advance level. These tutorials starts from Beginner level of Selenium in CSharp and move towards the Advance level.
  5. Using the Java class 'myclass' that we created in the previous tutorial, let us try to create a WebDriver script that would: fetch Mercury Tours' homepage verify its title print out the result of the comparison close it before ending the entire program. Note: Starting Firefox 35, you need to use.

Selenium is an open source, and its library is available in different programming languages to perform the Web UI Automation testing, and Python is one of them.

Selenium WebDriver Client Library for Python enables us to utilize all the features available with Selenium WebDriver and interact with Selenium Standalone Server to perform Automated testing (both remote and distributed testing) of browser-based applications.

It could be relevant for you to know about the team and its members who drove the development of the Selenium WebDriver Python libraries, they are Miki Tebeka, Adam Goucher, Eric Allenin, David Burns, Luke Semerau, Jason Huggins and MaikRoder.

The Selenium Webdriver library is compatible with a series of Python versions that includes Python 2.6, 2.7, and 3.2-3.5.

In this post, we’ll mainly discuss the following subjects so that you get acquainted with Selenium Webdriver Library for Python:

Table of Content

  • Prepare Your First Selenium Webdriver Automation Script Using Python
  • Creating Selenium Webdriver and Python Scripts for

Let’s now learn every little detail about setting up the Selenium Webdriver Python environment and write our first Selenium test script in Python.

Selenium Webdriver Python Setup for Web Automation

Installing Python

On Linux Distributions, MAC OS X, and Unix machines; Python is by default installed.

However, on Windows machines, it needs to be installed separately. Python installers for different Operating Systems are available at the following link:

For this tutorial, we’ve downloaded the latest version of Python (3.5.1) and used it for the examples given in the different sections of this tutorial. You can use the direct link given below to install the Python 3.5.1.

After you run the Python installer, it also installs the <pip> tool which is Python’s package manager. It facilitates the installation of advanced packages like the Selenium Webdriver.

Installing Selenium Webdriver Python Package

There are two unique ways to set up Selenium Webdriver with Python.

A- Use PIP package manager to install Selenium with Python

1- First go to the directory where you’ve installed Python.

For example, we have the latest Python version 3.5.1, and its location is in the <C:pythonpython35> folder.

2- Use the <pip> tool to install the Selenium Webdriver package.

If you want to upgrade the currently installed Selenium Webdriver package then, just add the -U flag to the previous <pip> command. Since we already have the latest version of the Selenium Webdriver library, the upgrade command will return the status as up-to-date.

This approach is the safest of all the methods available for installing Selenium with Python. The above commands will set up the Selenium WebDriver library on the system that contains all modules and classes required to create automated test scripts using Python.

The <pip> tool will download the latest version of the Selenium package and install it on your machine.

The optional –U flag will upgrade the existing version of the installed package to the latest version.

Selenium Webdriver Python Package Installation

B- Build Selenium Jar from Source and install with Python

1- Download the Selenium source code bundle from the below link. Extract the source into the folder <selenium-2.53.1> and follow the next step.

2- Now start the command prompt using cmd.exe and run the following command to install Selenium with Python:

Selecting Python Editor (IDE)

After we have set up Python and Selenium WebDriver, the next important step is to either pick an editor or an IDE (Integrated Development Environment) for writing the test scripts. A good editor or an IDE makes coding simple with their features. An IDE is even more powerful and comes with some excellent features like:

  • A graphical code editor with Code Completion feature.
  • Syntax highlighting.
  • Code explorer for functions and classes.
  • Managing Project structure.
  • Reporting and logging tool.
  • Tools for Debugging and Unit Testing.

Text editors like Vim, Nano or Notepad, are available to write the Python test scripts.

But IDEs are more convenient to work on large projects, so here we are giving a brief overview of some of the famous ones:

Popular Python IDEs for Development

a) PyCharm: It supports Windows, Linux, and Mac operating systems. PyCharm comes in two versions- community edition and professional edition. You can readily use its Community Edition as it is free. It has a Professional version which has more advanced features, but you’ve to purchase it.

Hence, the Community edition is suitable for creating and running Selenium test scripts. It has excellent debugging capabilities. To explore more about PyCharm and its features reach out the following link:

http://www.jetbrains.com/pycharm/

b) PyDev Eclipse plugin: PyDev is Python IDE for Eclipse.PyDev can be installed as a plug-in via the Eclipse update manager using the following update site: http://pydev.org/updates

You can see the detailed installation instructions at:

http://www.vogella.com/tutorials/Python/article.html

c) PyScripter: PyScripter is free and open-source Python IDE for Windows. It isn’t compatible with Linux. It provides an extensive blend of features that modern IDEs offer such as IntelliSense and code completion, testing, and debugging support. More details about PyScripter and its download information is available at the following link:

https://code.google.com/p/pyscripter/

With this, we are ready to create and run our test scripts using Selenium and Python.

Prepare Your First Selenium Webdriver Automation Script Using Python

Let’s start with Selenium WebDriver and create a Python script that uses Selenium classes and functions to automate browser interaction.

Here we will show you a sample script that opens “www.google.com” enters a search text in the Google search text box. Test script then verifies the Google search page on which has the searched text displayed.

Selenium Webdriver Python Script for Firefox

Decoding the above script

Let’s discuss the script line by line to get a better understanding of the Selenium WebDriver statements in brief. There will be a lot more about different Selenium WebDriver functions in upcoming posts.

Step-1.

The selenium webdriver module implements the classes that support different browsers including Firefox, Chrome, Internet Explorer, Safari, others, and RemoteWebDriver too to test on browsers available on remote machines.

We need to import webdriver from the Selenium package to use the Selenium WebDriver methods as:

from selenium import webdriver

Step-2.

Next, we need the object of the browser which we’ll use to load the web page. The browser object provides a programmable interface to communicate with the browser using the Selenium commands. In the test script, we are using Firefox. We can create an instance of the Firefox as shown in the following code:

driver = webdriver.Firefox()

On executing this statement, a new Firefox window will launch. We had made the following settings for the driver instance:

driver.implicitly_wait(30)
driver.maximize_window()

We configured a timeout for Selenium to launch the browser in 30 seconds. Next statement maximizes the browser window.

Step-3.

Next, we will navigate to the application, in our case ‘http://www.google.com,’ passing the given URL to the driver.get() method. After making a call to the get() method, Webdriver waits until the page gets rendered in the browser window and sends the control back to the script.

After the page gets loaded, Selenium will interact with various elements on the page. Next, in the test script, we will be looking at different Selenium WebDriver functions that search an HTML object, send a text to the web component, simulate keypress event, click buttons and select from drop downs, etc. Let’s see all these functions getting used in the next step.

Step-4.

* First of all, we’ll locate the Google Search textbox to supply the text input for the Search. The Search text box has an id attribute as <lst-ib>, and you can identify it from the code given below:

search_field = driver.find_element_by_id(<lst-ib>)

* After locating the Search text box, we are trying to interact with the textbox element by clearing the previous value using the clear() method and then using the send_keys() method to provide a new value. Subsequently calling the submit() method will forward the search request for processing. You can see a quick preview of these steps in the next few lines.

search_field.clear()
search_field.send_keys(“Selenium WebDriver Interview questions”)
search_field.submit()

* After submitting the search request, Firefox driver will display the result page returned by Google. The result page shows a list of entries that match the searched text. Each of the entry in the list is captured in anchor <a> element and can be accessed using “find_elements_by_class_name” method. If used, it will return a list of elements as:

lists= driver.find_elements_by_class_name(“_Rm”)

* The list of items expands to many pages, so we are restricting our code to print first ten entries captured in the anchor tag. We are outputting the names of the entries using the “innerHTML” property of the anchor <a> elements:

This example gave us a real insight into using Selenium WebDriver and Python together to create a simple test automation script. It is a very basic example script. We will use other interesting and complicated features of Selenium Library with Python in our upcoming posts.

Creating Selenium Webdriver Python Script for Internet Explorer and Google Chrome

Selenium supports cross-browser testing which means we can automate other browsers like Internet Explorer, Google Chrome, Safari and headless browsers like PhantomJS.

In this section, we will reuse the test script created in the earlier for the Internet Explorer and Google Chrome to verify the cross-browser capabilities of Selenium WebDriver.

Setting up Internet Explorer (IE)

To run the Selenium test scripts in the Internet Explorer, you first need to download and set up the InternetExplorerDriver server. This driver is a standalone server executable which enforces the WebDriver’s wire protocol to work as a link between the test script and Internet Explorer browser.

It supports most of the IE versions on Windows XP, Vista, Windows 7 and Windows 8 operating systems.

Following are the steps to set up the InternetExplorerDriver server:

i.Download the InternetExplorerDriver server from the mentioned link http://www.seleniumhq.org/download/. Both 32 and 64-bit versions are available for download. We have to choose based on our system configuration.

ii.Extract the downloaded InternetExplorerDriver server and copy the file to the same directory where the test scripts reside.

iii.Next, you need to check the Protected Mode setting (in IE 7 or higher). It must have the same value for each security zone. You can keep it on or off as long as it is the same for all the zones. Following are the steps to modify the Protected Mode settings in IE:

a. Choose Internet Options from the Tools menu.

b. From the Internet Options dialog, click on the Security tab.

c. Select each zone listed in “Select a zone to view or change security settings” and make sure that “Enable Protected Mode” (may require restarting your browser) is either on or off for all the zones. It is advisable for all the zones to have similar settings as shown in the image as given below:

iv. Finally, make the following modifications to the test script to open the website on Internet Explorer browser:

Selenium Webdriver Python Script for IE

Execution steps in the test script created for Internet Explorer are pretty much similar to what we did for Firefox.

Here one important point to note is that locators may get changed on different browsers so always verify them before using in the test scripts created for Selenium Test Automation.

Setting up Google Chrome (Chrome)

The above Selenium test automation script can also run on Google Chrome without making too many modifications.

You need to download the ChromeDriver server library similar to the InternetExplorerDriver. The ChromeDriver server is a standalone server, and it implements WebDriver’s wire protocol for automating Google Chrome.

This Selenium driver is compatible with Windows, Linux, and OS X operating systems. You can download the ChromeDriver server using the below steps:

i. Get the latest library of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html.

ii. Extract the downloaded ChromeDriver and copy the file to the same directory where the test scripts reside.

iii. Finally, make the following modifications to the test script for opening the website in the Chrome browser:

Selenium Webdriver Python Script for Chrome

Upon executing the above test script, Selenium will first launch the Chromedriver server, which starts the Chrome browser and performs the steps. This execution is very similar to what you’ve seen with Firefox and the Internet Explorer above.

Summary – Selenium Webdriver Python Tutorial

We’ve tried to make this Selenium Webdriver Python tutorial as intuitive as we could. Multiple examples that we’ve added can help you to get a quick heads-up on while working with Selenium using Python.

However, if you like to go to the next level and wish to create a test automation suite in Selenium Python, then do follow the below tutorial.

+ Step by Step Tutorial to Build a Selenium Python Test Suite

Please write to us about the Selenium Webdriver Python tutorial and share your views. Also please share this post on social media, use the share icons just below the post.

Keep Learning and Continue Practicing for Better Results.

-TechBeamers

Using the Java class 'myclass' that we created in the previous tutorial, let us try to create a WebDriver script that would:

  1. fetch Mercury Tours' homepage
  2. verify its title
  3. print out the result of the comparison
  4. close it before ending the entire program.

WebDriver Code

Below is the actual WebDriver code for the logic presented by the scenario above

Note: Starting Firefox 35, you need to use gecko driver created by Mozilla to use Web Driver. Selenium 3.0, gecko and firefox has compatibility issues and setting them correctly could become an uphill task. If the code does not work, downgrade to Firefox version 47 or below. Alternatively, you can run your scripts on Chrome. Selenium works out of the box for Chrome. You just need to change 3 lines of code to make your script work with Chrome or Firefox

Explaining the code

Importing Packages

To get started, you need to import following two packages:

  1. org.openqa.selenium.*- contains the WebDriver class needed to instantiate a new browser loaded with a specific driver
  2. org.openqa.selenium.firefox.FirefoxDriver - contains the FirefoxDriver class needed to instantiate a Firefox-specific driver onto the browser instantiated by the WebDriver class

If your test needs more complicated actions such as accessing another class, taking browser screenshots, or manipulating external files, definitely you will need to import more packages.

Instantiating objects and variables

Normally, this is how a driver object is instantiated.

A FirefoxDriver class with no parameters means that the default Firefox profile will be launched by our Java program. The default Firefox profile is similar to launching Firefox in safe mode (no extensions are loaded).

For convenience, we saved the Base URL and the expected title as variables.

Launching a Browser Session

C# Tutorial For Beginners

WebDriver's get() method is used to launch a new browser session and directs it to the URL that you specify as its parameter.

Get the Actual Page Title

The WebDriver class has the getTitle() method that is always used to obtain the page title of the currently loaded page.

Compare the Expected and Actual Values

This portion of the code simply uses a basic Java if-else structure to compare the actual title with the expected one.

Terminating a Browser Session

The 'close()' method is used to close the browser window.

Terminating the Entire Program

If you use this command without closing all browser windows first, your whole Java program will end while leaving the browser window open.

Running the Test

There are two ways to execute code in Eclipse IDE.

  1. On Eclipse's menu bar, click Run > Run.
  2. Press Ctrl+F11 to run the entire code.

If you did everything correctly, Eclipse would output 'Test Passed!'

Locating GUI Elements

Locating elements in WebDriver is done by using the 'findElement(By.locator())' method. The 'locator' part of the code is same as any of the locators previously discussed in the Selenium IDE chapters of these tutorials. Infact, it is recommended that you locate GUI elements using IDE and once successfully identified export the code to webdriver.

Here is a sample code that locates an element by its id. Facebook is used as the Base URL.

We used the getTagName() method to extract the tag name of that particular element whose id is 'email'. When run, this code should be able to correctly identify the tag name 'input' and will print it out on Eclipse's Console window.

Summary for locating elements
VariationDescriptionSample
By.classNamefinds elements based on the value of the 'class' attributefindElement(By.className('someClassName'))
By.cssSelectorfinds elements based on the driver's underlying CSS Selector enginefindElement(By.cssSelector('input#email'))
By.idlocates elements by the value of their 'id' attributefindElement(By.id('someId'))
By.linkTextfinds a link element by the exact text it displaysfindElement(By.linkText('REGISTRATION'))
By.namelocates elements by the value of the 'name' attributefindElement(By.name('someName'))
By.partialLinkTextlocates elements that contain the given link textfindElement(By.partialLinkText('REG'))
By.tagNamelocates elements by their tag namefindElement(By.tagName('div'))
By.xpathlocates elements via XPathfindElement(By.xpath('//html/body/div/table/tbody/tr/td[2]/table/tbody/tr[4]/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[3]/ form/table/tbody/tr[5]'))

Note on Using findElement(By.cssSelector())

By.cssSelector() does not support the 'contains' feature. Consider the Selenium IDE code below -

In Selenium IDE above, the entire test passed. However in the WebDriver script below, the same test generated an error because WebDriver does not support the 'contains' keyword when used in the By.cssSelector() method.

Common Commands

Instantiating Web Elements

Instead of using the long 'driver.findElement(By.locator())' syntax every time you will access a particular element, we can instantiate a WebElement object for it. The WebElement class is contained in the 'org.openqa.selenium.*' package.

Clicking on an Element

Clicking is perhaps the most common way of interacting with web elements. The click() method is used to simulate the clicking of any element. The following example shows how click() was used to click on Mercury Tours' 'Sign-In' button.

Following things must be noted when using the click() method.

  • It does not take any parameter/argument.
  • The method automatically waits for a new page to load if applicable.
  • The element to be clicked-on, must be visible (height and width must not be equal to zero).

Get Commands

Get commands fetch various important information about the page/element. Here are some important 'get' commands you must be familiar with.
get()Sample usage:
  • It automatically opens a new browser window and fetches the page that you specify inside its parentheses.
  • It is the counterpart of Selenium IDE's 'open' command.
  • The parameter must be a String object.
getTitle()Sample usage:
  • Needs no parameters
  • Fetches the title of the current page
  • Leading and trailing white spaces are trimmed
  • Returns a null string if the page has no title
getPageSource()Sample usage:
  • Needs no parameters
  • Returns the source code of the page as a String value
getCurrentUrl()Sample usage:
  • Needs no parameters
  • Fetches the string representing the current URL that the browser is looking at
getText()Sample usage:
  • Fetches the inner text of the element that you specify

Navigate commands

These commands allow you to refresh,go-into and switch back and forth between different web pages.
navigate().to()Sample usage:
  • It automatically opens a new browser window and fetches the page that you specify inside its parentheses.
  • It does exactly the same thing as the get() method.
navigate().refresh()Sample usage:
  • Needs no parameters.
  • It refreshes the current page.
navigate().back()Sample usage:
  • Needs no parameters
  • Takes you back by one page on the browser's history.
navigate().forward()Sample usage:
  • Needs no parameters
  • Takes you forward by one page on the browser's history.

Closing and Quitting Browser Windows

close()Sample usage:
  • Needs no parameters
  • It closes only the browser window that WebDriver is currently controlling.
quit()Sample usage:
  • Needs no parameters
  • It closes all windows that WebDriver has opened.

To clearly illustrate the difference between close() and quit(), try to execute the code below. It uses a webpage that automatically pops up a window upon page load and opens up another after exiting.

Notice that only the parent browser window was closed and not the two pop-up windows.

But if you use quit(), all windows will be closed - not just the parent one. Try running the code below and you will notice that the two pop-ups above will automatically be closed as well.

Switching Between Frames

To access GUI elements in a Frame, we should first direct WebDriver to focus on the frame or pop-up window first before we can access elements within them. Let us take, for example, the web page http://demo.guru99.com/selenium/deprecated.html

This page has 3 frames whose 'name' attributes are indicated above. We wish to access the 'Deprecated' link encircled above in yellow. In order to do that, we must first instruct WebDriver to switch to the 'classFrame' frame using the 'switchTo().frame()' method. We will use the name attribute of the frame as the parameter for the 'frame()' part.

After executing this code, you will see that the 'classFrame' frame is taken to the 'Deprecated API' page, meaning that our code was successfully able to access the 'Deprecated' link.

Switching Between Pop-up Windows

WebDriver allows pop-up windows like alerts to be displayed, unlike in Selenium IDE. To access the elements within the alert (such as the message it contains), we must use the 'switchTo().alert()' method. In the code below, we will use this method to access the alert box and then retrieve its message using the 'getText()' method, and then automatically close the alert box using the 'switchTo().alert().accept()' method.

First, head over to http://jsbin.com/usidix/1 and manually click the 'Go!' button there and see for yourself the message text.

Speakers View and Download Jensen SP1790JK user manual online. 900MHz Wireless Indoor/Outdoor Speakers. SP1790JK Speakers pdf manual download.

Lets see the WebDriver code to do this-

On the Eclipse console, notice that the printed alert message is:

C Programming Tutorial

Waits

There are two kinds of waits.

  1. Implicit wait - used to set the default waiting time throughout the program
  2. Explicit wait - used to set the waiting time for a particular instance only

Implicit Wait

  • It is simpler to code than Explicit Waits.
  • It is usually declared in the instantiation part of the code.
  • You will only need one additional package to import.

To start using an implicit wait, you would have to import this package into your code.

Then on the instantiation part of your code, add this.

Explicit Wait

Explicit waits are done using the WebDriverWait and ExpectedCondition classes. For the following example, we shall wait up to 10 seconds for an element whose id is 'username' to become visible before proceeding to the next command. Here are the steps.

Step 1

Import these two packages:

Step 2

Declare a WebDriverWait variable. In this example, we will use 'myWaitVar' as the name of the variable.

Step 3

Use myWaitVar with ExpectedConditions on portions where you need the explicit wait to occur. In this case, we will use explicit wait on the 'username' (Mercury Tours HomePage) input before we type the text 'tutorial' onto it.

Page 7 ENGLISH Page 7 Owner’s Manual Zodiac ® Baracuda ® / G3 PRO Suction-Side Pool Cleaner ™ ™ Operation and Maintenance Fine Tuning Cleaner Performance The G3 / G3 PRO cycles on/off with the pool filtration pump vacuuming and cleaning all surfaces randomly throughout the pool. View and Download Zodiac Baracuda G3 owner's manual online. AUTOMATIC INGROUND POOL CLEANER. Baracuda G3 Swimming Pool Vacuum pdf manual download. View and Download Zodiac Baracuda G3 installation manual online. INGROUND AUTOMATIC POOL CLEANER. Baracuda G3 Swimming Pool Vacuum pdf manual download. Also for: Baracuda g3 w03000. Zodiac pool care, inc. Will not be responsible for liner damage caused by (1) a baracuda g3 cleaner which is in disrepair, (2) pattern removal from a vinyl liner, or (3) a baracuda g3 cleaner used in a pool having an aged or deteriorated liner. Warranty procedures. Baracuda zodiac g3 manual.

Conditions

Following methods are used in conditional and looping operations --

  • isEnabled() is used when you want to verify whether a certain element is enabled or not before executing a command.
  • isDisplayed() is used when you want to verify whether a certain element is displayed or not before executing a command.

Selenium Webdriver Tutorial W3school

  • isSelected() is used when you want to verify whether a certain check box, radio button, or option in a drop-down box is selected. It does not work on other elements.

Using ExpectedConditions

The ExpectedConditions class offers a wider set of conditions that you can use in conjunction with WebDriverWait's until() method.

Selenium Webdriver Tutorial For Beginners

Below are some of the most common ExpectedConditions methods.

  • alertIsPresent() - waits until an alert box is displayed.
  • elementToBeClickable() - Waits until an element is visible and, at the same time, enabled. The sample code below will wait until the element with to become visible and enabled first before assigning that element as a WebElement variable named 'txtUserName'.
  • frameToBeAvailableAndSwitchToIt() - Waits until the given frame is already available, and then automatically switches to it.

Catching Exceptions

When using isEnabled(), isDisplayed(), and isSelected(), WebDriver assumes that the element already exists on the page. Otherwise, it will throw a NoSuchElementException. To avoid this, we should use a try-catch block so that the program will not be interrupted.

If you use explicit waits, the type of exception that you should catch is the 'TimeoutException'.

  • To start using the WebDriver API, you must import at least these two packages.
  • org.openqa.selenium.*
  • org.openqa.selenium.firefox.FirefoxDriver
  • The get() method is the equivalent of Selenium IDE's 'open' command.
  • Locating elements in WebDriver is done by using the findElement() method.
  • The following are the available options for locating elements in WebDriver:
  • By.className
  • By.cssSelector
  • By.id
  • By.linkText
  • By.name
  • By.partialLinkText
  • By.tagName
  • By.xpath
  • The By.cssSelector() does not support the 'contains' feature.
  • You can instantiate an element using the WebElement class.
  • Clicking on an element is done by using the click() method.
  • WebDriver provides these useful get commands:
  • get()
  • getTitle()
  • getPageSource()
  • getCurrentUrl()
  • getText()
  • WebDriver provides these useful navigation commands
  • navigate().forward()
  • navigate().back()
  • navigate().to()
  • navigate().refresh()
  • The close() and quit() methods are used to close browser windows. Close() is used to close a single window; while quit() is used to close all windows associated to the parent window that the WebDriver object was controlling.
  • The switchTo().frame() and switchTo().alert() methods are used to direct WebDriver's focus onto a frame or alert, respectively.
  • Implicit waits are used to set the waiting time throughout the program, while explicit waits are used only on specific portions.
  • You can use the isEnabled(), isDisplayed(),isSelected(), and a combination of WebDriverWait and ExpectedConditions methods when verifying the state of an element. However, they do not verify if the element exists.
  • When isEnabled(), isDisplayed(),or isSelected() was called while the element was not existing, WebDriver will throw a NoSuchElementException.
  • When WebDriverWait and ExpectedConditions methods were called while the element was not existing, WebDriver would throw a TimeoutException.

Selenium Webdriver Tutorial Python

Note:

Selenium Webdriver Tutorial Java

driver.get() : It's used to go to the particular website , But it doesn't maintain the browser History and cookies so , we can't use forward and backward button , if we click on that , page will not get schedule

driver.navigate() : it's used to go to the particular website , but it maintains the browser history and cookies, so we can use forward and backward button to navigate between the pages during the coding of Testcase