POM
This commit is contained in:
38
lukanPlaywright/.gitignore
vendored
Normal file
38
lukanPlaywright/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
lukanPlaywright/.idea/.gitignore
generated
vendored
Normal file
8
lukanPlaywright/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
lukanPlaywright/.idea/encodings.xml
generated
Normal file
7
lukanPlaywright/.idea/encodings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
14
lukanPlaywright/.idea/misc.xml
generated
Normal file
14
lukanPlaywright/.idea/misc.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
lukanPlaywright/.idea/vcs.xml
generated
Normal file
6
lukanPlaywright/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
58
lukanPlaywright/pom.xml
Normal file
58
lukanPlaywright/pom.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<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>cz.lukan</groupId>
|
||||
<artifactId>lukanPlaywright</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>lukanPlaywright</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.35.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<!-- References to interface static methods are allowed only at source level 1.8 or above -->
|
||||
<configuration>
|
||||
<source>20</source>
|
||||
<target>20</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -0,0 +1,4 @@
|
||||
package cz.lukan.base;
|
||||
|
||||
public class BaseClass {
|
||||
}
|
14
lukanPlaywright/src/main/java/cz/lukan/pages/HomePage.java
Normal file
14
lukanPlaywright/src/main/java/cz/lukan/pages/HomePage.java
Normal 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();
|
||||
}
|
||||
}
|
52
lukanPlaywright/src/test/java/cz/lukan/cookies.java
Normal file
52
lukanPlaywright/src/test/java/cz/lukan/cookies.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
33
lukanPlaywright/src/test/java/cz/lukan/klikacka.java
Normal file
33
lukanPlaywright/src/test/java/cz/lukan/klikacka.java
Normal file
@ -0,0 +1,33 @@
|
||||
package cz.lukan;
|
||||
|
||||
import com.microsoft.playwright.*;
|
||||
import com.microsoft.playwright.options.AriaRole;
|
||||
|
||||
public class klikacka {
|
||||
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.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("O mně")).click();
|
||||
page.getByText("Accept").click();
|
||||
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Zásady ochrany osobních údajů")).click();
|
||||
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Úvodní stránka")).click();
|
||||
page.locator("//*[@id=\"post-1225\"]/header/div/h2/a").click();
|
||||
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Úvodní stránka")).click();
|
||||
}
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user