![](https://habrastorage.org/getpro/habr/upload_files/631/6a9/0dd/6316a90dd02195dfb513137bc883912e.png)
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, .
![](https://habrastorage.org/getpro/habr/upload_files/8c3/120/893/8c3120893f196f8f7b78af32bf43b9c4.png)
![](https://habrastorage.org/getpro/habr/upload_files/213/97c/085/21397c0859908562edc90b476e2f830a.png)
- 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, . , - .
![](https://habrastorage.org/getpro/habr/upload_files/13e/36b/6bb/13e36b6bb232370976d1ac291a5cf342.png)
![](https://habrastorage.org/getpro/habr/upload_files/f78/c2c/5da/f78c2c5dab5412b6b54419ca36b36af2.png)
![](https://habrastorage.org/getpro/habr/upload_files/77d/10e/c1d/77d10ec1d075e0c00512af1a22c12542.png)
- 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 โ .