-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Saurabh-LT/main
Added Java PW Sample
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Run SmartUI Tests With Java Playwright On LambdaTest. | ||
|
||
Command to execute | ||
|
||
npx smartui exec -- mvn test -D suite=sdk-playwright-java.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"@lambdatest/smartui-cli": "^4.0.17" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>smartUI</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<release>10</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.19.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<suiteXmlFiles> | ||
<!--suppress UnresolvedMavenProperty --> | ||
<suiteXmlFile>${suite}</suiteXmlFile> | ||
</suiteXmlFiles> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>4.27.0</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/org.testng/testng --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.17.0</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --> | ||
<dependency> | ||
<groupId>io.github.bonigarcia</groupId> | ||
<artifactId>webdrivermanager</artifactId> | ||
<version>5.9.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.playwright</groupId> | ||
<artifactId>playwright</artifactId> | ||
<version>1.49.0</version> <!-- Use latest stable version --> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/io.github.lambdatest/lambdatest-java-playwright-sdk --> | ||
<dependency> | ||
<groupId>io.github.lambdatest</groupId> | ||
<artifactId>lambdatest-java-playwright-sdk</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.lambdatest; | ||
|
||
import com.microsoft.playwright.Browser; | ||
import com.microsoft.playwright.BrowserType; | ||
import com.microsoft.playwright.Page; | ||
import com.microsoft.playwright.Playwright; | ||
import io.github.lambdatest.SmartUISnapshot; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
public class SmartUISDKPlaywright { | ||
private Playwright playwright; | ||
private Browser browser; | ||
private Page page; | ||
|
||
// Setup Playwright and Browser | ||
@BeforeMethod | ||
public void setup() { | ||
playwright = Playwright.create(); | ||
BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions() | ||
.setHeadless(false); | ||
browser = playwright.chromium().launch(launchOptions); | ||
page = browser.newPage(); | ||
System.out.println("Playwright Browser initiated"); | ||
} | ||
|
||
@Test | ||
public void basicTest() throws Exception { | ||
page.navigate("https://www.lambdatest.com/visual-regression-testing"); | ||
SmartUISnapshot.smartuiSnapshot(page, "SmartUI"); | ||
} | ||
|
||
@AfterMethod | ||
public void tearDown() { | ||
if (browser != null) { | ||
browser.close(); | ||
} | ||
if (playwright != null) { | ||
playwright.close(); | ||
} | ||
} | ||
|
||
} |