×

Selenium WebDriver- Microsoft Edge Browser

Selenium WebDriver- Microsoft Edge Browser:

In this tutorial, we will learn how to launch the Microsoft Edge browser in the Selenium WebDriver.

Before we start automating our test script with Microsoft Edge browser using Selenium, we need to make sure that,

  • We should have Windows-10 installed in our machine.
  • After that, download the Microsoft WebDriver server version for your OS builds.
  • And try to use the latest version of Selenium (version 3.0 and above).

We will create this test case in the same test suite (new_test), which we created in the previous tutorial.

Step1:

  • Firstly, right-click on the src folder and create a new Class File from New ? Class.
Selenium web driver- Microsoft Edge Browser
  • And Give your Class name as Test_edge and click onthe Finish button.
Selenium web driver- Microsoft Edge Browser 1

Step2:

  • Firstly, we have to check the version of our OS builds. Based on our OS version build, we have to download the Edge driver.
  • And then go to Start ? Settings ? about this app to move to the Edge browser.
  •  The settings window would be displayed, in the below screenshot.
  • Remember the release number written next to OS Build. In this case, it is 15063, as shown in the above image.

Step3:

  • Now, go to the Selenium community, and download the Edge driver server.
  • In the Selenium community, find the third party driver division, and click on the Microsoft edge driver link which is shown in the below image,
Selenium web driver- Microsoft Edge Browser 3

Or

Directly open the below link, it will navigate you to the download page of Microsoft Edge driver in your browser.

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

  • Move your cursor downward little bit till you see the Downloads section.
  • And download the one which matches your build number.
  • In this case, we will click on Release 15063 and download it.
Selenium web driver- Microsoft Edge Browser 4

Step4:

  • Then, download the zip file into our local system, and unzip the folder, it will generate MicrosoftWebDriver.exe file automatically.
Selenium web driver- Microsoft Edge Browser 5

Step5:

  • Run the server before launching the Edge browser, with the  help of

System.property.

Syntax:

System.SetProperty(“key”, ”value”);

To set the system property for MicrosoftWebDriver where

Key = “webdriver.edge.driver”

And the path of your MicrosoftWebDriver.exe file to invoke the MicrosoftWebDriver class.

Value=”C:\Users\JTP\Downloads\microsoft edge driver\MicrosoftWebDriver.exe"

Sample code for the system property:

// System Property for Edge Driver   
System.setProperty("webdriver.edge.driver","C:\Users\JTP\Downloads\microsoft edge river\MicrosoftWebDriver.exe");
// create an object for EdgeDriver class.
WebDriver driver=new EdgeDriver();   

Let us see one sample test case, where we will try to automate the following scenarios in the Microsoft Edge browser.

Steps Actions Input Excepted Result
1. Open the Microsoft Edge browser.     The Microsoft Edge browser should be opened.
2. Navigate to the URL https://twitter.com/login?lang=en The twitter login page must be displayed.
3. Pass the value in the username text box. Username=admin Username value should be entered.
4. Pass the value in the password text box.   Password=admin Password value should be entered.
5. Click on the login button.     The login button should be clicked.
6. Capture the title of the home page.     The title of the home page should be captured.
7. Verify the title of the home page.     The title of the home page should be verified.
8. Close the browser.   The browser should be closed.

Here, the sample code for the above example:

package testpackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class test_edge {
public static void main(String[] args) throws InterruptedException { 
// System Property for Edge driver
System.setProperty("webdriver.edge.driver","C:\Users\JTP\Downloads\microsoft edge driver\MicrosoftWebDriver.exe");
// Step1: Launch the Microsoft Edge browser.
 WebDriver driver=new EdgeDriver();
// Step2: Open URL 
driver.get("https://twitter.com/login?lang=en");
// Step3: Pass the value in the username text box.
driver.findElement(By.xpath("//input[@placeholder='Phone, email or username']1]")).sendKeys("admin");
Thread.sleep(2000);
System.out.println("user name entered successfully");
// Step4: Pass the value in the password text box.
driver.findElement(By.xpath("//div[@class='clearfixfield']//input
[@placeholder='Password']")).sendKeys("admin");
Thread.sleep(2000);
System.out.println("password entered successfully "); 
// Step5: Click on login button.
driver.findElement(By.className("clearfix")).click();
System.out.println("login successfully");
// Step6: Capture the title of the home page. 
String exp_title="Login on Twitter";
String act_title=driver.getTitle();
// Step7: Verify the title of the home page. 
if(exp_title.equals(act_title))
{
System.out.println("test passed");
}
else {
System.out.println("test failed");
}
// Step8: Close the browser.
driver.close(); 
}
} 
  • Now, right-click on the Eclipse code and select Run as → Java Application.
  • The output of the above test script would be displayed in the Microsoft Edge browser.
Selenium web driver- Microsoft Edge Browser 6
  • The output of all print command of the above test script would be displayed in the Eclipse console window.
Selenium web driver- Microsoft Edge Browser 7

 

 


Related Topics

First test case of Selenium-IDE

First Test Case of Selenium-IDE: In this part, we are discussing how to create a basic test case in Selenium-IDE: The entire test script execution process in Selenium -IDE can be divided...

4 minutes read.

Operational Controls Methods in Selenium WebDriver

Operational Controls Methods The Operational controls are used to perform all the actions on the web elements like click on the button, pass the value in the text box, and click...

4 minutes read.

Selenium WebDriver-CSS Selector: Tag and ID

Selenium WebDriver-CSS Selector: Tag and ID We will locate the web element with the help of tag and id CSS selector in this section of the tutorials Where Tag and id are...

4 minutes read.

Drawback or Limitations of Selenium

Drawback or Limitations of Selenium Followings are the Drawback or limitations of Selenium:- Drawback /LimitationsDescriptionDesktop applications cannot be automated by Selenium.To test the desktop application, we have tools like Test Complete, Winnium, and...

2 minutes read.

Selenium WebDriver-CSS Selector: Tag Class and Attribute

Selenium WebDriver-CSS Selector: Tag, Class, and Attribute We will locate the web element with the help of Tag, class, and attribute CSS selector locator in this section of the tutorial. Where Tag,...

5 minutes read.

WebDriver-Name Locator:

WebDriver-Name Locator: The name locator is used to identify any element in UI with the help of the name backend attribute. The Syntax of the name attribute is as below: driver.findElement(By.name(“value of the...

4 minutes read.

CSS Selector: ID in Selenium IDE

CSS Selector: ID The id attribute is used to identify the web element uniquely in the web pages. Syntax of ID Attribute:  [HTML tag][#][Value of ID attribute] The hash sign (#): it is mandatory while using the...

1 minute read.

CSS Selector: Attribute in Selenium IDE

CSS Selector: Attribute Locating the attribute of a CSS selector, we would access the Password textbox, which is present in the login form of Facebook. The Password textbox has a type attribute...

1 minute read.

Selenium WebDriver installation

Installation Steps of Selenium WebDriver In this tutorial, we will see the process of selenium webdriver installation. Selenium WebDriver installation process is done in four Stages: Java Installation (version 8 or higher version) Eclipse...

4 minutes read.

Selenium WebDriver - Browser Controls Commands

Selenium WebDriver - Browser Controls Commands WebDriver includes operations like opening a browser, fetch the title, and closing the browser, etc. Some of the most commonly used Browser controls commands for Selenium WebDriver...

6 minutes read.

Selenium WebDriver – Window handling

Selenium WebDriver – Window handling In this tutorial, we will understand how we can handle the window, multiple windows, and pop-ups in selenium WebDriver. We have different types of window, and pop-ups...

7 minutes read.

WebDriver-Class Name Locator

WebDriver-Class Name Locator In this tutorial, we will learn about the Class name locator of selenium WebDriver. The Class Name locator is used to identify any element in UI based on the...

4 minutes read.

CSS Selector: Sub String in Selenium IDE

CSS Selector: Sub String CSS Selector Sub-string is used to match a partial string to locate a particular web element. There are three ways to match a substring using a CSS Selector. Match...

2 minutes read.

WebDriver-Tag Name Locator

Selenium WebDriver-Tag Name Locator The tag name locator is used along with the findElements() method to identify multiple similar elements in the UI. It is used to locate the web element with...

3 minutes read.

Characteristics of Selenium IDE

Characteristics of Selenium IDE Selenium IDE is separated into different parts, each having their features and functionalities. The seven various components of Selenium IDE are as follows: MENU BAR: The menu bar is...

3 minutes read.

CSS Selector: Inner text in Selenium IDE

CSS Selector: Inner text The inner text is used to identify and create a CSS Selector using a string pattern of the HTML tag which is displayed on the web page. Syntax...

1 minute read.

Name Locator in Selenium IDE

NAME LOCATOR: It is used to find the name in the web element. If we have multiple web elements of the same name, then the first matched element would be returned. Open the...

3 minutes read.

Selenium WebDriver-Alert Popup

Selenium WebDriver-Alert Popup  An alert popup is one of the small message boxes, which used to give some information to the user that displays on the browser. The Alert popup will be...

6 minutes read.

Selenium IDE Commands

Selenium –IDE Commands (SELENESE): Selenese commands are the set of commands used in Selenium IDE. Selenese command has two parameters target and value. Selenese command tests the existence of UI elements based on their HTML tags,...

3 minutes read.

XPath Axes Selenium WebDriver

XPath Axes XPath axes are those axes that are used to search for the multiple nodes in the XML document from the current node context. These methods are mainly used when the...

14 minutes read.