playwright
This commit is contained in:
parent
1892b1cefa
commit
6fa38ba917
38
playwrightLukan/.gitignore
vendored
Normal file
38
playwrightLukan/.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
playwrightLukan/.idea/.gitignore
generated
vendored
Normal file
8
playwrightLukan/.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
playwrightLukan/.idea/encodings.xml
generated
Normal file
7
playwrightLukan/.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
playwrightLukan/.idea/misc.xml
generated
Normal file
14
playwrightLukan/.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
playwrightLukan/.idea/vcs.xml
generated
Normal file
6
playwrightLukan/.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>
|
51
playwrightLukan/pom.xml
Normal file
51
playwrightLukan/pom.xml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<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>
|
||||||
|
<name>Archetype - playwrightLukan</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
|
<artifactId>selenium-java</artifactId>
|
||||||
|
<version>4.11.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</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>
|
44
playwrightLukan/src/java/test/cookies.java
Normal file
44
playwrightLukan/src/java/test/cookies.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
playwrightLukan/src/java/test/klikacka.java
Normal file
33
playwrightLukan/src/java/test/klikacka.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<archetype>
|
||||||
|
<id>playwrightLukan</id>
|
||||||
|
<sources>
|
||||||
|
<source>src/main/java/App.java</source>
|
||||||
|
</sources>
|
||||||
|
<testSources>
|
||||||
|
<source>src/test/java/AppTest.java</source>
|
||||||
|
</testSources>
|
||||||
|
</archetype>
|
@ -0,0 +1,15 @@
|
|||||||
|
<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>
|
@ -0,0 +1,13 @@
|
|||||||
|
package $cz.lukan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user