This commit is contained in:
Lukáš Kaňka 2023-08-21 21:02:47 +02:00
parent dbd498f34e
commit 02d72d127d
21 changed files with 208 additions and 182 deletions

View File

@ -5,16 +5,11 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e313fd9a-aaf7-4ddf-8596-2ccbfcf66da1" name="Changes" comment=""> <list default="true" id="e313fd9a-aaf7-4ddf-8596-2ccbfcf66da1" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> <change afterPath="$PROJECT_DIR$/../Selenite_Naveen/driver/geckodriver.exe" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" /> <change afterPath="$PROJECT_DIR$/../Selenite_Naveen/src/test/java/cz/lukan/LaunchBrowser.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/readme.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/cz/lukan/App.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/test/java/cz/lukan/AppTest.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/test/java/cz/lukan/AppTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/cz/lukan/AppTest.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../Selenium_POM_tutorial/src/main/java/POM/pages/_03/HomePage.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../Selenium_POM_tutorial/src/main/java/POM/pages/_03/LoginPage.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../Selenium_POM_tutorial/src/test/java/tutorial/POM/tests/Test_03_Login_POM.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../Selenium_POM_tutorial/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../Selenium_POM_tutorial/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../Selenium_POM_tutorial/readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/../Selenium_POM_tutorial/readme.md" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -27,9 +22,9 @@
<component name="MarkdownSettingsMigration"> <component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" /> <option name="stateVersion" value="1" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"associatedIndex": 0 &quot;associatedIndex&quot;: 0
}]]></component> }</component>
<component name="ProjectId" id="2U7PFC389YXq1L1vFeL6SYyRrNb" /> <component name="ProjectId" id="2U7PFC389YXq1L1vFeL6SYyRrNb" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
@ -41,6 +36,7 @@
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false", "WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "main", "git-widget-placeholder": "main",
"last_opened_file_path": "C:/Users/lukas/Nextcloud/GitHub/Java/Selenium_Selenide_Playwright_JAVA/PlaywrightTestAcademy",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
@ -48,6 +44,26 @@
"vue.rearranger.settings.migration": "true" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<component name="RunManager">
<configuration name="AppTest" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="cz.lukan.AppTest" />
<module name="PlaywrightTestAcademy" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="cz.lukan.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.AppTest" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
@ -57,6 +73,7 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1692287544970</updated> <updated>1692287544970</updated>
<workItem from="1692287547085" duration="2032000" /> <workItem from="1692287547085" duration="2032000" />
<workItem from="1692637254673" duration="321000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -1,38 +1,15 @@
package cz.lukan; package cz.lukan;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/** import com.microsoft.playwright.*;
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/** public class AppTest {
* @return the suite of tests being tested public static void main(String[] args) {
*/ try (Playwright playwright = Playwright.create()) {
public static Test suite() Browser browser = playwright.firefox().launch();
{ Page page = browser.newPage();
return new TestSuite( AppTest.class ); page.navigate("http://playwright.dev");
System.out.println(page.title() + " " + "Test is OK!");
}
} }
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

Binary file not shown.

View File

@ -0,0 +1,25 @@
package cz.lukan;
import com.codeborne.selenide.Configuration;
import org.openqa.selenium.By;
import org.testng.annotations.Test;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
public class LaunchBrowser {
@Test
public void testBrowser() {
// System.setProperty("webdriver.gecko.driver", "C:\\Users\\lukas\\Nextcloud\\GitHub\\Java\\Selenium_Selenide_Playwright_JAVA\\Selenite_Naveen\\driver\\geckodriver.exe");
// Configuration.browser = "firefox";
Configuration.headless = true;
open("https://www.google.com/");
// Odmítnutí cookie
$ (By.id("W0wltc")).click();
}
}

View File

@ -1,38 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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/maven-v4_0_0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>cz.lukan</groupId> <groupId>cz.lukan</groupId>
<artifactId>playwrightLukan</artifactId> <artifactId>lukanPlaywright</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<name>Archetype - playwrightLukan</name> <packaging>jar</packaging>
<name>lukanPlaywright</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.13.2</version> <version>3.8.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.microsoft.playwright</groupId> <groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId> <artifactId>playwright</artifactId>
<version>1.35.1</version> <version>1.35.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
<version>RELEASE</version> <version>RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
@ -49,3 +55,4 @@
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -0,0 +1,4 @@
package cz.lukan.base;
public class BaseClass {
}

View File

@ -0,0 +1,14 @@
package cz.lukan.pages;
import com.microsoft.playwright.Page;
public class HomePage {
private final Page page;
public HomePage(Page page) {this.page = page; }
String acceptCookie = "Accept";
public void clickAcceptCookies() {
page.getByText(acceptCookie).click();
}
}

View File

@ -0,0 +1,52 @@
package cz.lukan;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.testng.annotations.Test;
import java.nio.file.Paths;
public class cookies {
Page page;
@BeforeEach
public void setUp() {
}
@AfterEach
public void tearDown() {
page.close();
page.context().close();
}
@Test
void Accept() {
Playwright playwright = Playwright.create();
Browser browser = Playwright.create().chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
Page page = browser.newPage();
page.navigate("https://lukan.cz");
page.getByText( "Accept").click();
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("example.png")));
}
@Test
void Decline() {
Playwright playwright = Playwright.create();
Browser browser = Playwright.create().chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
Page page = browser.newPage();
page.navigate("https://lukan.cz");
page.getByText("Decline").click();
}
}

View File

@ -0,0 +1,31 @@
package cz.lukan;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import cz.lukan.pages.HomePage;
import org.testng.annotations.Test;
public class cookiesPageObject {
Page page;
HomePage homePage;
@Test
void Accept() {
homePage = new HomePage(page);
Playwright playwright = Playwright.create();
Browser browser = Playwright.create().chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
Page page = browser.newPage();
page.navigate("https://lukan.cz");
homePage.clickAcceptCookies();
}
}

View File

@ -0,0 +1,18 @@
package cz.lukan;
import com.microsoft.playwright.*;
public class cookiesPlaywright {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate("https://lukan.cz/");
page.getByText("Accept").click();
}
}
}

View File

@ -1,4 +1,4 @@
package test; package cz.lukan;
import com.microsoft.playwright.*; import com.microsoft.playwright.*;
import com.microsoft.playwright.options.AriaRole; import com.microsoft.playwright.options.AriaRole;

View File

@ -1,44 +0,0 @@
package test;
import com.microsoft.playwright.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class cookies {
// Shared between all tests in this class.
static Playwright playwright;
static Browser browser;
// New instance for each test method.
BrowserContext context;
Page page;
@BeforeEach
public void setUp() {
Browser browser = Playwright.create().chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
BrowserContext context = browser.newContext();
page = context.newPage();
}
@AfterEach
public void tearDown() {
page.close();
page.context().close();
page.close();
}
@Test
void Accept() {
page.navigate("https://lukan.cz");
page.getByText( "Accept").click();
}
@Test
void Decline() {
page.navigate("https://lukan.cz");
page.getByText("Decline").click();
}
}

View File

@ -1,9 +0,0 @@
<archetype>
<id>playwrightLukan</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>

View File

@ -1,15 +0,0 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>$cz.lukan</groupId>
<artifactId>$playwrightLukan</artifactId>
<version>$1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,13 +0,0 @@
package $cz.lukan;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -1,38 +0,0 @@
package $cz.lukan;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}