first
This commit is contained in:
commit
a8f58c8ec4
40
SeleniumBasic/.gitignore
vendored
Normal file
40
SeleniumBasic/.gitignore
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/
|
||||||
|
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
SeleniumBasic/.idea/.gitignore
generated
vendored
Normal file
8
SeleniumBasic/.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
SeleniumBasic/.idea/encodings.xml
generated
Normal file
7
SeleniumBasic/.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
SeleniumBasic/.idea/misc.xml
generated
Normal file
14
SeleniumBasic/.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_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
SeleniumBasic/.idea/vcs.xml
generated
Normal file
6
SeleniumBasic/.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>
|
39
SeleniumBasic/pom.xml
Normal file
39
SeleniumBasic/pom.xml
Normal 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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>kankys</groupId>
|
||||||
|
<artifactId>SeleniumBasic</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Archetype - SeleniumBasic</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||||
|
<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>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,9 @@
|
|||||||
|
<archetype>
|
||||||
|
<id>SeleniumBasic</id>
|
||||||
|
<sources>
|
||||||
|
<source>src/main/java/App.java</source>
|
||||||
|
</sources>
|
||||||
|
<testSources>
|
||||||
|
<source>src/test/java/AppTest.java</source>
|
||||||
|
</testSources>
|
||||||
|
</archetype>
|
15
SeleniumBasic/src/main/resources/archetype-resources/pom.xml
Normal file
15
SeleniumBasic/src/main/resources/archetype-resources/pom.xml
Normal file
@ -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>$kankys</groupId>
|
||||||
|
<artifactId>$SeleniumBasic</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 $kankys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package $kankys;
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
BIN
SeleniumBasic/src/main/resources/drivers/geckodriver.exe
Normal file
BIN
SeleniumBasic/src/main/resources/drivers/geckodriver.exe
Normal file
Binary file not shown.
39
SeleniumBasic/src/test/java/ClickMeTest.java
Normal file
39
SeleniumBasic/src/test/java/ClickMeTest.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
|
public class ClickMeTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/clickmebaby.php");
|
||||||
|
// message jsem udělal do getText vložit "" vyjmout --> vlažit kam chci psát
|
||||||
|
Assert.assertEquals("Inicaálizovaný počet kliků", "0", driver.findElement(By.id("clicks")).getText());
|
||||||
|
// for cyklus zvyšování plus 1
|
||||||
|
for (int i = 1; i <11 ; i++) {
|
||||||
|
driver.findElement(By.id("clickMe")).click();
|
||||||
|
Assert.assertEquals(String.valueOf(i),driver.findElement(By.id("clicks")).getText());
|
||||||
|
if (i==1){
|
||||||
|
System.out.println("ověřujem slovo klik");
|
||||||
|
Assert.assertEquals("klik",driver.findElement(By.className("desription")).getText());
|
||||||
|
}
|
||||||
|
// dálší info video 28
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
36
SeleniumBasic/src/test/java/CssSelectorTest.java
Normal file
36
SeleniumBasic/src/test/java/CssSelectorTest.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
|
public class CssSelectorTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/kalkulacka.php");
|
||||||
|
// id
|
||||||
|
driver.findElement(By.cssSelector("button#count")).click();
|
||||||
|
// class - trida
|
||||||
|
driver.findElement(By.cssSelector("button.btn-success")).click();
|
||||||
|
|
||||||
|
driver.get(BASE_URL + "/clickmebaby.php");
|
||||||
|
// tlačítko je v poli container a v něm je button
|
||||||
|
driver.findElement(By.cssSelector("div.container button")).click();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
// driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
30
SeleniumBasic/src/test/java/MySecondTest.java
Normal file
30
SeleniumBasic/src/test/java/MySecondTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
// @neco je metota těmi začneme psát test
|
||||||
|
// void = metoda nevrací žádnou hodnotu
|
||||||
|
// setUP, test, tearDown názvy metod mohu si je pojmenovat jak chci
|
||||||
|
|
||||||
|
public class MySecondTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/clickmebaby.php");
|
||||||
|
driver.findElement(By.id("clickMe")).click();
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
32
SeleniumBasic/src/test/java/MyThirdTest.java
Normal file
32
SeleniumBasic/src/test/java/MyThirdTest.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
// @neco je metota těmi začneme psát test
|
||||||
|
// void = metoda nevrací žádnou hodnotu
|
||||||
|
// setUP, test, tearDown názvy metod mohu si je pojmenovat jak chci
|
||||||
|
|
||||||
|
public class MyThirdTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/registracia.php");
|
||||||
|
driver.findElement(By.name("email")).sendKeys("franta@borec.cz");
|
||||||
|
driver.findElement(By.name("name")).sendKeys("Franta");
|
||||||
|
driver.findElement(By.xpath("//form/div[3]/input")).sendKeys("frantík");
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
50
SeleniumBasic/src/test/java/SelectTest.java
Normal file
50
SeleniumBasic/src/test/java/SelectTest.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
public class SelectTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
private StringBuffer verificationErrors = new StringBuffer();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
//System.setProperty("webdriver.gecko.driver", "src/test/resources/drivers/geckodriver.exe");
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/vybersi.php");
|
||||||
|
new Select(driver.findElement(By.className("form-control"))).selectByIndex(1);
|
||||||
|
new Select(driver.findElement(By.className("form-control"))).selectByValue("02");
|
||||||
|
new Select(driver.findElement(By.className("form-control"))).selectByVisibleText("Pikachu");
|
||||||
|
// výpis textu
|
||||||
|
System.out.println(driver.findElement(By.xpath("//div/h3")).getText());
|
||||||
|
// kontrola jestli se v textu nalézá Pikachu
|
||||||
|
Assert.assertTrue("Pikachu se v textu nenachází", driver.findElement(By.xpath("//div/h3")).getText().contains("Pikachu"));
|
||||||
|
// kontrola jestli se nenalézé něco jiného v textu ( v tomto prípadě Gizela)
|
||||||
|
Assert.assertFalse(driver.findElement(By.xpath("//div/h3")).getText().contains("Gizela"));
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
String verificationErrorString = verificationErrors.toString();
|
||||||
|
if (!"".equals(verificationErrorString)) {
|
||||||
|
fail(verificationErrorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
SeleniumBasic/src/test/java/TabulkaTest.java
Normal file
28
SeleniumBasic/src/test/java/TabulkaTest.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
|
public class TabulkaTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/tabulka.php");
|
||||||
|
// video 31
|
||||||
|
driver.findElement(By.xpath("//table/tbody/tr[last()]/td[1]")).getText();
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
26
SeleniumBasic/src/test/java/VzorTest.java
Normal file
26
SeleniumBasic/src/test/java/VzorTest.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
|
public class VzorTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
27
SeleniumBasic/src/test/java/XpathTest.java
Normal file
27
SeleniumBasic/src/test/java/XpathTest.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
|
public class XpathTest {
|
||||||
|
private WebDriver driver;
|
||||||
|
private final String BASE_URL = "http://localhost";
|
||||||
|
@Before
|
||||||
|
public void setUp(){
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
driver.get(BASE_URL + "/tabulka.php");
|
||||||
|
driver.findElement(By.xpath("/html/body/div/div/table/thead/tr"));
|
||||||
|
|
||||||
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown(){
|
||||||
|
// driver.quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user