series - elemn

This commit is contained in:
Lukáš Kaňka 2023-08-16 16:00:32 +02:00
parent a8f58c8ec4
commit 233f276f6f
78 changed files with 1632 additions and 8 deletions

38
BrowserStackJunit/.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

8
BrowserStackJunit/.idea/.gitignore 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

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>

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_X" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

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,7 @@
Install:
Maven build
Selenide: https://selenide.org/quick-start.html
Junit5: search Juni t5 --> install Hunit Jupiter API

37
BrowserStackJunit/pom.xml Normal file
View File

@ -0,0 +1,37 @@
<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.kankys</groupId>
<artifactId>BrowserStackSelenideJunitKiwi</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Archetype - BrowserStackJunit</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>6.17.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>20</source>
<target>20</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,9 @@
<archetype>
<id>BrowserStackJunit</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>

View 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>$cz.kankys</groupId>
<artifactId>$BrowserStackJunit</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>

View File

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

View File

@ -0,0 +1,38 @@
package $cz.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 );
}
}

View File

@ -0,0 +1,30 @@
package tests;
import com.codeborne.selenide.WebDriverRunner;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Cookie;
import static com.codeborne.selenide.Selectors.byAttribute;
import static com.codeborne.selenide.Selectors.byXpath;
import static com.codeborne.selenide.Selenide.*;
public class KiwiTest {
@Test
void itShouldOpenMainPage() {
open("https://www.kiwi.com/en");
// Cookie (org.openqa.selenium), tento způsob nepůjde na všech webech. Všude to je jinde
//cookie_consent, agreed --> takto si to pojmenovalo kiwi
// nakonec za komentovaný způsob nešel použil jsem xpath
/*
Cookie cookie = new Cookie("cookie_consent", "agreed");
WebDriverRunner.getWebDriver().manage().addCookie(cookie);
//refresh();
*/
$(byXpath("//*[@id=\"cookies_accept\"]")).click();
$(byAttribute("data-test" ,"LandingSearchButton")).click();
System.out.println("");
}
}

View File

@ -0,0 +1,27 @@
package tests;
import org.junit.jupiter.api.Test;
import static com.codeborne.selenide.Selectors.byAttribute;
import static com.codeborne.selenide.Selectors.byXpath;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
public class OveritCenuLetenkyTest {
@Test
void OverimeCenuLetenky() {
// jdeme na web kiwi
open("https://www.kiwi.com/cz/");
// potvrdíme cooki
$(byXpath("//*[@id=\"cookies_accept\"]")).click();
// kliknu na hlavni strane na prozkoumat
$(byAttribute("data-test" ,"LandingSearchButton")).click();
// kliknu na prvni nabídku na strance
$(byAttribute("data-test" ,"PictureCardContent")).click();
// pockam na nactení letenek
// ulozim si cenu letenky do promenne
// otevrem detail letenky a porovnam cenu
}
}

Binary file not shown.

View File

@ -1,13 +1,15 @@
package cz.lukan;
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 {
public class AlertTest {
private WebDriver driver;
private final String BASE_URL = "http://localhost";
// video 33 výpis do konzole textu
@Before
public void setUp(){
driver = new ChromeDriver();
@ -15,9 +17,8 @@ public class TabulkaTest {
}
@Test
public void test(){
driver.get(BASE_URL + "/tabulka.php");
// video 31
driver.findElement(By.xpath("//table/tbody/tr[last()]/td[1]")).getText();
driver.get(BASE_URL);
}
@After

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -5,18 +7,20 @@ 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;
public class ClickMeTest {
private WebDriver driver;
private final String BASE_URL = "http://localhost";
private final String BASE_URL = "http://localhost/clickmebaby.php";
@Before
public void setUp(){
driver = new ChromeDriver();
System.setProperty("webdriver.gecko.driver" , "geckodriver.exe");
driver = new FirefoxDriver();
}
@Test
public void test(){
driver.get(BASE_URL + "/clickmebaby.php");
driver.get(BASE_URL);
// 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

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -0,0 +1,40 @@
package cz.lukan;
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.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.List;
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();
// vide 32
List<WebElement> rows = driver.findElements(By.xpath("//table/tbody/tr"));
System.out.println(rows);
for (WebElement roow : rows) {
System.out.println(roow.getText());
}
}
@After
public void tearDown(){
driver.quit();
}
}

View File

@ -0,0 +1,16 @@
package cz.lukan;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
SelectTest.class,
ClickMeTest.class,
XpathTest.class
})
public class TestSuite {
}

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,3 +1,5 @@
package cz.lukan;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

3
selenide_series/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<excludeFromCompile>
<directory url="file://$PROJECT_DIR$/src/main/resources/archetype-resources" includeSubdirectories="true" />
</excludeFromCompile>
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="selenide_series" />
</profile>
</annotationProcessing>
</component>
</project>

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>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

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_X" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

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>

28
selenide_series/pom.xml Normal file
View File

@ -0,0 +1,28 @@
<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>selenide_series</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Archetype - selenide_series</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
</properties>
<dependencies>
<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>

12
selenide_series/readme.md Normal file
View File

@ -0,0 +1,12 @@
Selenide ---> https://selenide.org/quick-start.html (pom.xml)
TestNG ---> https://mvnrepository.com/artifact/org.testng/testng (pom.xml)
Maven --->
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
</properties>

View File

@ -0,0 +1,9 @@
<archetype>
<id>selenide_series</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>

View 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>$cz.lukan</groupId>
<artifactId>$selenide_series</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>

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,29 @@
package specs;
import com.codeborne.selenide.WebDriverRunner;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import static com.codeborne.selenide.Selenide.open;
import static com.codeborne.selenide.Selenide.title;
import static org.testng.AssertJUnit.assertEquals;
public class HomeTest {
@Test
public void testPageUrlAndTitle() {
open("https://practice.sdetunicorns.com/");
// test očekávané url, String url do této proměné jsme vložily url
String url = WebDriverRunner.url();
assertEquals(url, "https://practice.sdetunicorns.com/");
// test titulu stránky
String title = title();
assertEquals(title, "Practice E-Commerce Site SDET Unicorns Helping you succeed in Software Quality.");
}
@Test
public void testInteractingWithElements() {
}
}

View File

@ -0,0 +1,9 @@
<archetype>
<id>selenide_series</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>

View 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>$cz.lukan</groupId>
<artifactId>$selenide_series</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>

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

8
selenidetraining/.idea/.gitignore 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

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="selenide-training" />
<module name="selenidetraining" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

View File

@ -0,0 +1,12 @@
<?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_X" default="true" project-jdk-name="20" project-jdk-type="JavaSDK" />
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

36
selenidetraining/pom.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>furbo.sk</groupId>
<artifactId>selenide-training</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>6.17.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

View File

@ -0,0 +1,24 @@
package base;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class TestBase {
protected WebDriver driver;
protected final String BASE_URL = "http://localhost:8888";
@Before
public void setUp() {
//System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/mac/chromedriver75_mac");
driver = new ChromeDriver();
}
@After
public void tearDown() {
driver.close();
driver.quit();
}
}

View File

@ -0,0 +1,89 @@
package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
public class SavingsCalculatorPage {
@FindBy(id = "emailInput")
private WebElement emailInput;
@FindBy(id = "yearsInput")
private WebElement yearsInput;
@FindBy(id = "oneTimeInvestmentInput")
private WebElement oneTimeInvestmentInput;
@FindBy(id = "fundSelect")
private WebElement fundSelect;
@FindBy(css = "button.btn")
private WebElement applyButton;
@FindBy(css = "div.result")
private WebElement resultElement;
@FindBy(css = "ul.saving-list div.saving-detail")
private WebElement mostRecentSavingsDetail;
private WebDriver pageDriver;
public SavingsCalculatorPage(WebDriver driver) {
this.pageDriver = driver;
PageFactory.initElements(driver, this);
}
public void enterEmail(String email) {
emailInput.clear();
emailInput.sendKeys(email);
emailInput.sendKeys(Keys.TAB);
}
public void enterYears(int years) {
yearsInput.clear();
yearsInput.sendKeys(String.valueOf(years));
}
public void enterOneTimeInvestment(String amount) {
oneTimeInvestmentInput.clear();
oneTimeInvestmentInput.sendKeys(amount);
}
public void selectFund(String fundToSelect) {
new Select(fundSelect).selectByVisibleText(fundToSelect);
}
public void applyForSaving() {
applyButton.click();
}
public WebElement getCalculatedTotalIncomeElement() {
return resultElement.findElement(By.xpath("./div[1]/p"));
}
public WebElement getCalculatedInterestIncomeElement() {
return pageDriver.findElement(By.cssSelector("div.result > div:nth-child(2) p"));
}
public WebElement getCalculatedRiskElement() {
return resultElement.findElement(By.xpath("./div[3]/p"));
}
public WebElement getRecentRequestDetail() {
return mostRecentSavingsDetail;
}
public WebElement getApplyButton() {
return applyButton;
}
public WebElement getEmailInputWrapper(){
return pageDriver.findElement(By.xpath("//input[@id='emailInput']/.."));
}
}

View File

@ -0,0 +1,18 @@
package suites;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import tests.*;
@RunWith(Suite.class)
@Suite.SuiteClasses({
FellowshipTest.class,
GosslingatorTest.class,
RandomTableTest.class,
SavingsCalculatorTest.class,
SortingHatTest.class,
WaitForItTest.class,
SpelleologyTest.class
})
public class TestSuite {
}

View File

@ -0,0 +1,103 @@
package tests;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import base.TestBase;
public class FellowshipTest extends TestBase {
@Before
public void openPage() {
driver.get(BASE_URL + "/fellowship.php");
}
@Test
public void itShouldContainNameForEachFellow() {
List<WebElement> fellowElements = getFellowElements();
for (WebElement fellowElement : fellowElements) {
Assert.assertFalse(fellowElement.findElement(By.cssSelector("h1")).getText().isEmpty());
}
}
@Test
public void itShouldContainSpecifiedFellows() {
List<WebElement> fellowElements = getFellowElements();
List<String> fellowNames = new ArrayList<String>();
for (WebElement fellowElement : fellowElements) {
System.out.println(fellowElement.findElement(By.cssSelector("h1")).getText());
fellowNames.add(fellowElement.findElement(By.cssSelector("h1")).getText());
}
System.out.println(fellowNames);
Assert.assertTrue(fellowNames.contains("Gandalf"));
Assert.assertTrue(fellowNames.contains("Aragorn"));
Assert.assertTrue(fellowNames.contains("Frodo"));
}
@Test
public void itShouldDisplayMessageComplete() {
List<String> fellowsToSelect = new ArrayList<String>();
fellowsToSelect.add("Gandalf");
fellowsToSelect.add("Aragorn");
fellowsToSelect.add("Legolas");
fellowsToSelect.add("Frodo");
for (String fellowToSelect : fellowsToSelect) {
selectFellow(fellowToSelect);
}
Assert.assertEquals("Complete", driver.findElement(By.cssSelector("div.points-left h3")).getText());
}
@Test
public void itShouldDisplayPointsForEachFellow() {
List<WebElement> displayedFellows = getFellowElements();
for (WebElement displayedFellow : displayedFellows) {
String actualPoints = displayedFellow.findElement(By.cssSelector("div.fellow-points h2")).getText();
Assert.assertFalse(actualPoints.isEmpty());
}
}
@Test
public void itShouldHighlightFellows() {
List<String> fellowsToSelect = new ArrayList<String>();
fellowsToSelect.add("Gandalf");
fellowsToSelect.add("Aragorn");
fellowsToSelect.add("Legolas");
fellowsToSelect.add("Frodo");
for (String fellowToSelect : fellowsToSelect) {
selectFellow(fellowToSelect);
}
List<String> higlightedFellows =
driver.findElements(By.xpath("//ul[contains(@class,'list-of-fellows')]/li/div[contains(@class,'active')]//h1"))
.stream()
.map(WebElement::getText)
.collect(Collectors.toList());
for (String higlightedFellow : higlightedFellows) {
Assert.assertTrue(fellowsToSelect.contains(higlightedFellow));
}
}
private void selectFellow(String fellowName) {
driver.findElement(By.xpath("//h1[contains(text(),'" + fellowName + "')]")).click();
}
private List<WebElement> getFellowElements() {
return driver.findElements(By.cssSelector("ul.list-of-fellows li"));
}
}

View File

@ -0,0 +1,77 @@
package tests;
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.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class GosslingatorTest {
private WebDriver driver;
@Before
public void setUp() {
//System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver75_mac");
driver = new ChromeDriver();
driver.get("http://localhost:8888/gosslingator.php");
}
@Test
public void itShouldDisplayTitle() {
Assert.assertEquals("GOSLINGATE ME", driver.findElement(By.cssSelector(".ryan-title")).getText());
}
@Test
public void itShouldAddOneRyan() {
driver.findElement(By.id("addRyan")).click();
String actualNumberOfRyans = driver.findElement(By.id("ryanCounter")).getText();
Assert.assertEquals("1", actualNumberOfRyans);
System.out.println("Number of ryans: " + driver.findElement(By.cssSelector("div.ryan-counter h2")).getText());
Assert.assertEquals("ryan", driver.findElement(By.cssSelector("div.ryan-counter h3")).getText());
}
@Test
public void itShouldTwoRyans() {
driver.findElement(By.id("addRyan")).click();
driver.findElement(By.id("addRyan")).click();
String actualNumberOfRyans = driver.findElement(By.id("ryanCounter")).getText();
String actualRyanDescription = driver.findElement(By.cssSelector("div.ryan-counter h3")).getText();
Assert.assertEquals("2", actualNumberOfRyans);
Assert.assertEquals("ryans", actualRyanDescription);
}
@Test
public void itShouldDisplayWarningMessage() {
WebElement addRyanButton = driver.findElement(By.id("addRyan"));
for (int i = 0; i < 50; i++) {
addRyanButton.click();
}
Assert.assertEquals(
"NUMBER OF\n" +
"RYANS\n" +
"IS TOO DAMN\n" +
"HIGH",
driver.findElement(By.cssSelector("h1.tooManyRyans")).getText()
);
}
@Test
public void itShouldDisplayNoRyanOnPageOpen() {
Assert.assertEquals(0, driver.findElements(By.cssSelector("img")).size());
}
@After
public void tearDown() {
driver.close();
driver.quit();
}
}

View File

@ -0,0 +1,47 @@
package tests;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import base.TestBase;
public class RandomTableTest extends TestBase {
@Before
public void openPage() {
//1.otvorit stranku
driver.get(BASE_URL + "/tabulka.php");
}
@Test
public void itShouldContainDataForEachRow() {
for (WebElement tableRow : getRows()) {
Assert.assertFalse(tableRow.getText().isEmpty());
}
}
@Test
public void itShouldContainNameForEachRow() {
List<WebElement> tableRows = getRows();
for (WebElement tableRow : tableRows) {
tableRow.findElement(By.cssSelector("td:nth-child(2)"));
WebElement rowName = tableRow.findElement(By.xpath("./td[2]"));
Assert.assertFalse(rowName.getText().isEmpty());
}
}
@Test
public void itShouldScrollToLastElement() {
WebElement lastRow = driver.findElement(By.cssSelector("table > tbody > tr:last-child"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", lastRow);
}
private List<WebElement> getRows() {
return driver.findElements(By.cssSelector("table tbody tr"));
}
}

View File

@ -0,0 +1,98 @@
package tests;
import base.TestBase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import pages.SavingsCalculatorPage;
import static org.junit.Assert.*;
import static org.openqa.selenium.By.cssSelector;
public class SavingsCalculatorTest extends TestBase {
private SavingsCalculatorPage savingsCalculatorPage;
@Before
public void openPage() {
driver.get(BASE_URL.concat("/savingscalculator.php"));
savingsCalculatorPage = new SavingsCalculatorPage(driver);
}
@Test
public void itShouldEnableApplyButton() {
savingsCalculatorPage.selectFund("Hoggwart's Fund");
savingsCalculatorPage.enterOneTimeInvestment("15000");
savingsCalculatorPage.enterYears(20);
savingsCalculatorPage.enterEmail("info@furbo.sk");
assertTrue(savingsCalculatorPage.getApplyButton().isEnabled());
}
@Test
public void itShouldDisplayCalculatedAmounts() {
savingsCalculatorPage.selectFund("Hoggwart's Fund");
savingsCalculatorPage.enterOneTimeInvestment("15000");
savingsCalculatorPage.enterYears(20);
savingsCalculatorPage.enterEmail("info@furbo.sk");
assertFalse(savingsCalculatorPage.getCalculatedTotalIncomeElement().getText().isEmpty());
assertFalse(savingsCalculatorPage.getCalculatedInterestIncomeElement().getText().isEmpty());
}
@Test
public void itShouldDisplayCalculatedRisk() {
savingsCalculatorPage.selectFund("Hoggwart's Fund");
savingsCalculatorPage.enterOneTimeInvestment("15000");
savingsCalculatorPage.enterYears(20);
savingsCalculatorPage.enterEmail("info@furbo.sk");
assertFalse(savingsCalculatorPage.getCalculatedRiskElement().getText().isEmpty());
}
@Test
public void itShouldContainFundNameInNewRequest() {
String fundToSelect = "Hoggwart's Fund";
savingsCalculatorPage.selectFund(fundToSelect);
savingsCalculatorPage.enterOneTimeInvestment("25000");
savingsCalculatorPage.enterYears(20);
savingsCalculatorPage.enterEmail("info@furbo.sk");
savingsCalculatorPage.applyForSaving();
assertEquals(
fundToSelect,
savingsCalculatorPage.getRecentRequestDetail().findElement(cssSelector("p.fund-description")).getText()
);
}
@Test
public void itShouldDisplayErrorMessageWhenEmailIsInvalid() {
savingsCalculatorPage.enterEmail("invalid");
assertTrue(savingsCalculatorPage.getEmailInputWrapper().getAttribute("class").contains("error"));
}
@Test
public void itShouldHighlightNewRequestOnHover() throws InterruptedException {
savingsCalculatorPage.selectFund("Hoggwart's Fund");
savingsCalculatorPage.enterOneTimeInvestment("15000");
savingsCalculatorPage.enterYears(20);
savingsCalculatorPage.enterEmail("info@furbo.sk");
savingsCalculatorPage.applyForSaving();
Actions action = new Actions(driver);
WebElement we = driver.findElement(By.cssSelector("div.saving-detail"));
action.moveToElement(we).build().perform();
Thread.sleep(300);
assertEquals("rgba(4, 102, 156, 1)", we.getCssValue("background-color"));
}
}

View File

@ -0,0 +1,23 @@
package tests;
import base.TestBase;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class SortingHatTest extends TestBase {
@Test
public void itShouldDisplayNameOfHouse() {
driver.get(BASE_URL + "/sortinghat.php");
driver.findElement(By.cssSelector("button")).click();
new WebDriverWait(driver, 10)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("img.loading")));
new WebDriverWait(driver, 10)
.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("img.loading")));
Assert.assertFalse(driver.findElement(By.cssSelector("p.result")).getText().isEmpty());
}
}

View File

@ -0,0 +1,68 @@
package tests;
import base.TestBase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.List;
import java.util.stream.Collectors;
public class SpelleologyTest extends TestBase {
@Before
public void openPage() {
driver.get(BASE_URL + "/spelleology.php");
}
@Test
public void itShouldContainSpells() {
String[] spellsToBePresent = {
"counters sonorus",
"erases memories",
"counterspells",
"controls a person unforgivable"
};
new WebDriverWait(driver, 10)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.spells li")));
List<String> displayedSpells = driver.findElements(By.cssSelector("ul.spells li"))
.stream()
.map(WebElement::getText)
.collect(Collectors.toList());
for (String spellToCheck : spellsToBePresent) {
Assert.assertTrue(displayedSpells.contains(spellToCheck));
}
}
@Test
public void itShouldDisplayTortureSpell() {
new WebDriverWait(driver, 10)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.spells li")));
List<WebElement> spellElements = driver.findElements(By.cssSelector("ul.spells li"));
for (WebElement spellElement : spellElements) {
if (spellElement.getText().equals("tortures a person")) {
spellElement.click();
}
}
new WebDriverWait(driver, 10)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.modal-container")));
WebElement modal = driver.findElement(By.cssSelector("div.modal-container"));
Assert.assertTrue(modal.getText().contains("Crucio"));
}
@Test
public void itShouldFilterSpells() {
driver.findElement(By.cssSelector("input")).sendKeys("tortures a person");
new WebDriverWait(driver, 10).until(ExpectedConditions
.numberOfElementsToBe(By.cssSelector("ul.spells li"), 1));
Assert.assertEquals(driver.findElements(By.cssSelector("ul.spells li")).size(), 1);
}
}

View File

@ -0,0 +1,49 @@
package tests;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import base.TestBase;
public class WaitForItTest extends TestBase {
@Before
public void openPage() {
driver.get(BASE_URL + "/waitforit.php");
}
@Test
public void waitForValue() {
String expectedText = "dary !!!";
driver.findElement(By.id("startWaitForText")).click();
WebElement input = driver.findElement(By.id("waitForTextInput"));
new WebDriverWait(driver, 5)
.until(ExpectedConditions.attributeToBe(input, "value", expectedText));
Assert.assertEquals(expectedText, input.getAttribute("value"));
}
@Test
public void waitForClass() {
driver.findElement(By.id("startWaitForProperty")).click();
new WebDriverWait(driver, 10)
.until(ExpectedConditions.attributeContains(By.id("waitForProperty"),"class","error"));
}
@Test
public void itShouldDisplayResponseTimeMessage() {
driver.findElement(By.id("startWaitForText")).click();
new WebDriverWait(driver, 10).until(ExpectedConditions.textToBePresentInElement(
driver.findElement(By.cssSelector("div.current-wait-time")),
"Response time"));
Assert.assertTrue(driver.findElement(By.cssSelector("div.current-wait-time")).getText().contains("Response time"));
}
}

View File

@ -0,0 +1,16 @@
package utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.List;
import java.util.stream.Collectors;
public class DataUtils {
public static List<String> getExpectedSpells() throws FileNotFoundException {
FileReader fileReader = new FileReader(new File("src/test/resources/testData/spells.txt"));
BufferedReader br = new BufferedReader(fileReader);
return br.lines().collect(Collectors.toList());
}
}

View File

@ -0,0 +1,91 @@
summons an object
shoots water from wand
opens locked objects
clears the target's airway
reveals invisible ink
murders opponent
turns small objects into birds
launches birds from your wand
strengthens an enclosure from enemies
magically locks door
explodes flames on target
confuses opponent
damages opponents eyesight
tortures a person
digs out materials
counters `prior incatato`
enlarges teeth
blasts holes through walls and floors
splits seams
opens `one eyed witch` hump
makes objects hard
enlarges and item
counters stupefy
heals minor injuries
erects things
creates a patronus
disarms your opponent
makes objects explode
creates bandages
hides a secret within someone
stops any current spells
allows user to write on objects
knocks an object backwards
produces boils on opponent
duplicates an object
turns stairs into ramps
reveals humans nearby
cures werewolves (at least according to lockhart)
renders target immobile.
slows an advancing object
controls a person unforgivable
makes an object repel water
ties someone up
starts a fire
glues opponent's tongue to roof of mouth
allows the caster to delve into the mind of the victim
hangs victim upside down by feet
counterspells
locks opponents legs
creates light at wand tip
causes weather effect spells to stop
moves objects with wand
moves unconscious bodies
conjures the dark mark
prevents nearby people from listening to conversations
counters lumos
erases memories
blindfolds the victim
makes conjured items attack
conjures a bunch of flowers
packs a trunk (suitcase)
removes pixies (maybe)
binds body unforgivable
animates statues and armor suits
makes wand act like a compass
echoes most recent spells, result when brother wands duel
reveals a wands last spell / cast
causes spells to reflect back to the sender.
protects one from dark magic
protects area
counters sonorus
returns items to original size. counters engorgio
blasts solid objects aside
releases user from binding
cures unconsciousness
repairs things
keeps muggles away
tickles opponent
turns boggart into ridiculous form so you can laugh it away
protects against hexes
destroys ectoplasm (remains of ghosts)
causes wounds as if slashed by a sword
produces snake
silences victim
amplifies voice
reveals hidden secrets or magical properties
knocks out opponent
forces opponent to dance
cleans up messes
unsticks an object
makes on object fly

View File

@ -0,0 +1,91 @@
summons an object
shoots water from wand
opens locked objects
clears the target's airway
reveals invisible ink
murders opponent
turns small objects into birds
launches birds from your wand
strengthens an enclosure from enemies
magically locks door
explodes flames on target
confuses opponent
damages opponents eyesight
tortures a person
digs out materials
counters `prior incatato`
enlarges teeth
blasts holes through walls and floors
splits seams
opens `one eyed witch` hump
makes objects hard
enlarges and item
counters stupefy
heals minor injuries
erects things
creates a patronus
disarms your opponent
makes objects explode
creates bandages
hides a secret within someone
stops any current spells
allows user to write on objects
knocks an object backwards
produces boils on opponent
duplicates an object
turns stairs into ramps
reveals humans nearby
cures werewolves (at least according to lockhart)
renders target immobile.
slows an advancing object
controls a person unforgivable
makes an object repel water
ties someone up
starts a fire
glues opponent's tongue to roof of mouth
allows the caster to delve into the mind of the victim
hangs victim upside down by feet
counterspells
locks opponents legs
creates light at wand tip
causes weather effect spells to stop
moves objects with wand
moves unconscious bodies
conjures the dark mark
prevents nearby people from listening to conversations
counters lumos
erases memories
blindfolds the victim
makes conjured items attack
conjures a bunch of flowers
packs a trunk (suitcase)
removes pixies (maybe)
binds body unforgivable
animates statues and armor suits
makes wand act like a compass
echoes most recent spells, result when brother wands duel
reveals a wands last spell / cast
causes spells to reflect back to the sender.
protects one from dark magic
protects area
counters sonorus
returns items to original size. counters engorgio
blasts solid objects aside
releases user from binding
cures unconsciousness
repairs things
keeps muggles away
tickles opponent
turns boggart into ridiculous form so you can laugh it away
protects against hexes
destroys ectoplasm (remains of ghosts)
causes wounds as if slashed by a sword
produces snake
silences victim
amplifies voice
reveals hidden secrets or magical properties
knocks out opponent
forces opponent to dance
cleans up messes
unsticks an object
makes on object fly