In this article, we'll take a look at cross-browser testing. This is a type of testing that checks if an application works as expected across multiple browsers, operating systems, and devices. We can do cross-browser testing with and without automation. Automated test scripts can be written or created using programs such as TestProject and Selenium .
- , Selenium TestProject.
- ?
- , (AUT) , . . , , .
, - . - - Internet Explorer, , Chrome? - , AUT - .
-
- , . - . - , AUT, , . , .
(Test Script) . . Chrome Windows , Firefox Mac , .
, , . 2 TestProject. - - , (Chrome, Firefox Edge).
package tutorials.testproject;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class CrossBrowserTesting {
WebDriver driver;
@Test
@Parameters ( {"BrowserType"} )
public void testExamplePageOnMultipleBrowsers (String browserType) {
if (browserType.equalsIgnoreCase("Chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
else if (browserType.equalsIgnoreCase("Edge")) {
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
}
else if (browserType.equalsIgnoreCase("Firefox")) {
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
}
driver.manage().window().maximize();
driver.get("https://example.testproject.io/web/index.html");
System.out.println(browserType + ": " + driver.getTitle());
}
}
package tutorials.testproject;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class IndividualBrowserTesting {
WebDriver driver;
@Test
public void testExamplePageOnMultipleBrowsersOnChrome () {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://example.testproject.io/web/index.html");
System.out.println("Chrome: " + driver.getTitle());
}
@Test
public void testExamplePageOnMultipleBrowsersOnFirefox () {
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://example.testproject.io/web/index.html");
System.out.println("Chrome: " + driver.getTitle());
}
@Test
public void testExamplePageOnMultipleBrowsersOnEdge () {
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
driver.manage().window().maximize();
driver.get("https://example.testproject.io/web/index.html");
System.out.println("Chrome: " + driver.getTitle());
}
}
- , , .
, .
, , .
. 100% , , , , .
- Selenium?
- Selenium, (grid) . Selenium Grid , . Selenium Grid . .
Excel, CSV, , XML . TestNG - . DataProvider dataProvider dataProviderClass .
- , Parameters . , XML- Parameters.
<suite name="Cross Browser Testing">
<test name = "Test On Chrome">
<parameter name = "BrowserType" value="Chrome"/>
<classes>
<class name = "tutorials.testproject.CrossBrowserTesting"/>
</classes>
</test>
<test name = "Test On Edge">
<parameter name = "BrowserType" value="Edge"/>
<classes>
<class name = "tutorials.testproject.CrossBrowserTesting"/>
</classes>
</test>
<test name = "Test On Firefox">
<parameter name = "BrowserType" value="Firefox"/>
<classes>
<class name = "tutorials.testproject.CrossBrowserTesting"/>
</classes>
</test>
</suite>
package tutorials.testproject;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class CrossBrowserTesting {
WebDriver driver;
@Test
@Parameters ( {"BrowserType"} )
public void testExamplePageOnMultipleBrowsers (String browserType) {
if (browserType.equalsIgnoreCase("Chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
else if (browserType.equalsIgnoreCase("Edge")) {
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
}
else if (browserType.equalsIgnoreCase("Firefox")) {
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
}
driver.manage().window().maximize();
driver.get("https://example.testproject.io/web/index.html");
System.out.println(browserType + ": " + driver.getTitle());
}
}
XML- . , . , . , .. "BrowserType", @Parameters, , .. "Chrome", if else if.
if else if Chrome, Edge Firefox. XML-. , TestProject, .
- Selenium TestProject
OpenSDK /
2 - TestProject. OpenSDK AI-Powered Test Recorder. OpenSDK Selenium Java, C# Python. - Selenium . TestProject Maven Gradle, .
<dependency>
<groupId>io.testproject</groupId>
<artifactId>java-sdk</artifactId>
<version>0.65.0-RELEASE</version>
</dependency>
implementation 'io.testproject:java-sdk:0.65.0-RELEASE'
import io.testproject.sdk.drivers.web.ChromeDriver;
import io.testproject.sdk.drivers.web.FirefoxDriver;
import io.testproject.sdk.drivers.web.EdgeDriver;
AI-Powered Test Recorder
AI-Powered Test Recorder -, , Chrome, Edge Firefox. TestProject CSV, . , - .
- TestProject AI-Powered Test Recorder.
, - - . . , . - , .
- Selenium TestProject.
TestProject Java, C# Python OpenSDK . OpenSDK Selenium, Selenium TestProject. , TestProject's AI-Powered Test Recorder - . , , - .
"Java QA Engineer. Basic". - ยซ TestIT Jiraยป. , , . , , -, . โ Jira, TestIT โ .