playwright
This commit is contained in:
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 );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user