11/25/17

How To Run WebDriver Test Case using Microsoft Edge Browser


Download Microsoft WebDriver from here to launch Edge Browser. Download the proper version of the driver based on your OS build number. If the extension of the downloaded file is “.msi“, you need to install it to get the “.exe” driver.




Test Case:

1)Open Web Browser.
2)Open URL  http://opensource.demo.orangehrmlive.com
3)Enter username  (Admin).
4)Enter password  (admin).   
5)Click on Login.
6)Capture title of the home page.
7)Verify title of the page: OrangeHRM 

8) close browser

WebDriver script:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class EdgeBrowserTest {

public static void main(String[] args) throws InterruptedException {

// step1
System.setProperty("webdriver.edge.driver", "C:/Drivers/MicrosoftEdgeDriver/MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();

// step2
driver.get("http://opensource.demo.orangehrmlive.com");

// step3
driver.findElement(By.name("txtUsername")).sendKeys("Admin");

// step4
driver.findElement(By.name("txtPassword")).sendKeys("admin");

// step5
driver.findElement(By.name("Submit")).click();

Thread.sleep(5000);

String exp_title = "OrangeHRM";
String act_title = driver.getTitle(); // step6

if (exp_title.equals(act_title)) {     //step7
System.out.println(" test case passed");
} else {
System.out.println(" test case failed");
}
driver.close(); //step8
}


}












0 comments:

Post a Comment