This commit is contained in:
Lukáš Kaňka 2023-08-18 20:51:31 +02:00
parent 8884123171
commit cdc44d9d0b
24 changed files with 552 additions and 2 deletions

38
PlaywrightTestAcademy/.gitignore vendored Normal file
View 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

View 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
PlaywrightTestAcademy/.idea/misc.xml generated Normal file
View 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
PlaywrightTestAcademy/.idea/vcs.xml generated Normal file
View 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>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="e313fd9a-aaf7-4ddf-8596-2ccbfcf66da1" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/readme.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/cz/lukan/App.java" afterDir="false" />
<change 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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 0
}]]></component>
<component name="ProjectId" id="2U7PFC389YXq1L1vFeL6SYyRrNb" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "main",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="e313fd9a-aaf7-4ddf-8596-2ccbfcf66da1" name="Changes" comment="" />
<created>1692287544970</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1692287544970</updated>
<workItem from="1692287547085" duration="2032000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

View 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cz.lukan</groupId>
<artifactId>PlaywrightTestAcademy</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlaywrightTestAcademy</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.36.0</version>
</dependency>
<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>
</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>

View File

@ -0,0 +1,8 @@
https://www.youtube.com/watch?v=ycsl8Nd6H4I
New project --> vybrat org.apache.maven.archetypes:maven-archetype-quickstart
....................................................................
TestNG
playwright

View File

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

View File

@ -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 );
}
}

40
Selenid_Naeem2023/.gitignore vendored Normal file
View File

@ -0,0 +1,40 @@
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
/build/

8
Selenid_Naeem2023/.idea/.gitignore generated vendored Normal file
View 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
Selenid_Naeem2023/.idea/encodings.xml generated Normal file
View 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
Selenid_Naeem2023/.idea/misc.xml generated Normal file
View 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
Selenid_Naeem2023/.idea/vcs.xml generated Normal file
View 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>

View File

@ -0,0 +1,15 @@
https://www.youtube.com/watch?v=0V8sqgO9dSA&list=PLAieK72EyQbvCpMt7gThAHdpjfZUVmHPv&index=1
Maven
TestNG
Selenide
Na inportovat si:
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;
Nezapomenout --> Generata --> MethodTest

39
Selenid_Naeem2023/pom.xml Normal file
View File

@ -0,0 +1,39 @@
<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>Selenid_Naeem2023</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Selenid_Naeem2023</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>6.17.0</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>
</dependencies>
</project>

View File

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

View File

@ -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 );
}
}

View File

@ -0,0 +1,31 @@
package cz.lukan;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.SelenideElement;
import com.codeborne.selenide.WebDriverRunner;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import static com.codeborne.selenide.Selectors.byXpath;
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;
public class MercuryLoginTest {
@Test
public void testMercuryLogin() {
Configuration.browser="chrome";
Configuration.browserSize="1000x650";
Configuration.headless=true;
Configuration.screenshots=true;
Configuration.timeout=13000;
Configuration.holdBrowserOpen=true;
open("https://www.demo.guru99.com/test/newtours/");
//WebDriverRunner.getWebDriver().manage().window().maximize();
switchTo().frame(3);
$("#save > .mat-button-wrapper span").click();
$(By.name("userName")).setValue("test");
$(By.name("password")).setValue("test");
$(By.name("submit")).click();
$("h3").shouldHave(text("Login Successfully"));
}
}

View File

@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -11,4 +11,4 @@ TestNG
Selenium java Selenium java
WebDriverManager konec video 3

View File

@ -0,0 +1,21 @@
package POM.pages._03;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class HomePage {
WebDriver driver;
public HomePage(WebDriver driver){
this.driver = driver;
}
// pole na vyplnění user name password,identifikace polde id
private final By msg_footer = By.xpath("//*[@id=\"page_wrapper\"]/footer/div");
// ověríme text footer
public WebElement get_Msg_footer() {
return driver.findElement(msg_footer);
}
}

View File

@ -0,0 +1,30 @@
package POM.pages._03;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class LoginPage {
// Webdriver potřebujeme abych mohl vyplňovat pomocí funkce fill
WebDriver driver;
public LoginPage(WebDriver driver){
this.driver = driver;
}
// pole na vyplnění user name password,identifikace polde id
private final By textbox_username = By.id("user-name");
private final By textbox_password = By.name("password");
private final By btn_login = By.xpath("//*[@id=\"login-button\"]");
// Vyplnění údajů
public void fill_Textbox_username(String username) {
driver.findElement(textbox_username).sendKeys(username);
}
public void fill_Textbox_password(String password) {
driver.findElement(textbox_password).sendKeys(password);
}
public void click_Btn_Login() {
driver.findElement(btn_login).click();
}
}

View File

@ -0,0 +1,47 @@
package tutorial.POM.tests;
import POM.pages._02.HomePage;
import POM.pages._02.LoginPage;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class Test_03_Login_POM {
WebDriver driver;
@BeforeMethod
// open website
public void setup() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.get("https://www.saucedemo.com/");
driver.manage().window().maximize();
}
@Test
public void test_Login_Functionality() {
LoginPage loginPage = new LoginPage(driver);
loginPage.fill_Textbox_username("standard_user");
loginPage.fill_Textbox_password("secret_sauce");
loginPage.click_Btn_Login();
HomePage homePage = new HomePage(driver);
String actual_msg = homePage.get_Msg_footer().getText();
String expected_msg = " Sauce Labs. All Rights Reserved. Terms of Service | Privacy Policy";
Assert.assertTrue(actual_msg.contains(expected_msg));
}
// close browser
@AfterMethod
public void teardown() {
driver.quit();
}
}