Selenium with C# 53 - Cross Browser testing using selenium webdriver C# | Firefox, chrome, IE & Edge

Опубликовано: 30 Сентябрь 2024
на канале: Ankpro Training
6,749
27

Face book links
www.facebook.com/ankpro
www.facebook.com/ankprotraining

Agenda
Cross browser testing for Chrome browser
Cross browser testing for Firefox browser
Cross browser testing for IE browser
Cross browser testing for Edge browser

What is Cross Browser Testing?

Cross Browser Testing is a type of functional test to check that your web application works as expected in different browsers.

Cross browser testing is the process of comparing a website or web application’s functionality and design across multiple web browsers and platforms to ensure consistent behavior and functionality for the end-user. 

Why do we need Cross Browser Testing?

Web-based applications are totally different from Windows applications. A web application can be opened in any browser by the end user so we need to do cross browser testing.

Cross Browser Testing for Chrome Browser :

First we need to add Chrome driver from nuget package

[TestMethod]
public void LaunchChromeBrowser()
{
IWebDriver driver = new ChromeDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

Cross Browser Testing for Firefox Browser

First we need to add Gecko driver from nuget package

[TestMethod]
public void LaunchFirefoxBrowser()
{
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

Cross Browser Testing for IE Browser

First we need to add Internet Explorer driver from nuget package

[TestMethod]
public void LaunchIEBrowser()
{
IWebDriver driver = new InternetExplorerDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

Cross Browser Testing for Edge Browser

First we need to add Executable file for edge browser to the solution project

[TestMethod]
public void LaunchEdgeBrowser()
{
IWebDriver driver = new EdgeDriver();
driver.Url=("http://ankpro.com/");
driver.Quit();
}

Possible Interview Questions on cross browser selenium testing
What is cross browser testing
Why we need to do cross browser testing
How to do cross browser testing for Chrome browser
How to do cross browser testing for Firefox browser
How to do cross browser testing for IE browser
How to do cross browser testing for Edge browser


Cross browser testing code :


[TestMethod]
public void LunchFireFoxBrowser()
{
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

[TestMethod]
public void LunchChromeBrowser()
{
IWebDriver driver = new ChromeDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

[TestMethod]
public void LunchIEBrowser()
{
IWebDriver driver = new InternetExplorerDriver();
driver.Url = "http://ankpro.com/";
driver.Quit();
}

[TestMethod]
public void LunchEdgeBrowser()
{
IWebDriver driver = new EdgeDriver();
driver.Url=("http://ankpro.com/");
driver.Quit();
}