Finished app

This commit is contained in:
s464968 2024-02-16 14:06:36 +01:00
commit eb82652969
58 changed files with 29122 additions and 0 deletions

8
.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

13
.idea/compiler.xml Normal file
View File

@ -0,0 +1,13 @@
<?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="my-app" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml 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>

20
.idea/jarRepositories.xml Normal file
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>

12
.idea/misc.xml Normal file
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_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK" />
</project>

6
.idea/vcs.xml 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>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 KiB

92
pom.xml Normal file
View File

@ -0,0 +1,92 @@
<?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>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>7.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

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

View File

@ -0,0 +1,78 @@
package com.mycompany.app;
import static com.codeborne.selenide.CollectionCondition.allMatch;
import static com.codeborne.selenide.CollectionCondition.texts;
import static org.junit.Assert.assertTrue;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import com.codeborne.selenide.*;
import org.junit.Test;
import static com.codeborne.selenide.Condition.*;
/**
* Unit test for simple App.
*/
public class AppTest
{
AppTestPage home = new AppTestPage();
@Test
public void testURL() {
home.open().assertUrl();
}
@Test
public void testTitle() {
home.open().assertTitle();
}
@Test
public void testMenuLink() {
home.open();
home.getKulturaNavLink().click();
String url = WebDriverRunner.url();
assertTrue(url.contains("kultura"));
}
@Test
public void testIfLogoExist() {
home.open().getLogoLink().shouldBe(visible);;
}
@Test
public void testIfNavLinksHaveCorrectText() {
List<String> expectedLinks = Arrays.asList("NEWSY", "RECENZJE", "TEKSTY", "KULTURA", "WIDEO", "CZASOPISMO", "TECHNOLOGIE", "RETRO", "BAZA GIER", "NA LUZIE", "FORUM");
ElementsCollection linksList = home.open().getNavLinks();
linksList.shouldHave(texts(expectedLinks));
}
@Test
public void testIfArticleLinkAndArticleTitleMatch() {
home.open();
SelenideElement articleLink = home.getArticleLink().should(exist);
String articleLinkText = articleLink.text();
articleLink.click();
SelenideElement articleTitle = home.getArticleTitle().should(exist);
articleTitle.shouldHave(text(articleLinkText));
}
@Test
public void testIfSearchWorks() {
home.open().getSearchLink().click();
home.getSearchInput().val("aaaaa").pressEnter();
home.getSearchInput().should(exist);
ElementsCollection searchResults = home.getSearchResults();
List<String> searchResultTexts = searchResults.texts();
System.out.println(searchResultTexts);
for (String str: searchResultTexts){
assertTrue(str.matches("^.*(aaaaa|AAAAA).*$"));
}
}
}

View File

@ -0,0 +1,61 @@
package com.mycompany.app;
import com.codeborne.selenide.*;
import org.openqa.selenium.By;
import static com.codeborne.selenide.Condition.exist;
import static com.codeborne.selenide.Selenide.*;
import static org.junit.Assert.assertEquals;
public class AppTestPage {
public AppTestPage open(){
Configuration.browser = "firefox";
Configuration.timeout = 50000;
Configuration.headless = true;
Selenide.open("https://cdaction.pl/");
SelenideElement cookies = $("#cookiescript_accept");
if(cookies.exists()){
cookies.click();
}
return this;
}
public SelenideElement getKulturaNavLink(){
return $(By.xpath("//*[@id=\"__next\"]/header/div/nav/div/a[4]"));
}
public SelenideElement getLogoLink(){
return $(By.xpath("//a[@title=\"CD-Action\"]"));
}
public ElementsCollection getNavLinks(){
return $$(By.cssSelector("nav a"));
}
public SelenideElement getSearchLink(){
return $(By.xpath("//button[@aria-label=\"Wyszukiwarka\"]"));
}
public SelenideElement getArticleLink() {return $(By.xpath("//*[@id=\"maincontainer\"]/section[1]/div[1]/div[1]/div[1]/a/div[3]/h2"));}
public SelenideElement getArticleTitle() {return $(By.xpath("//*[@id=\"maincontainer\"]/section[2]/div[2]/h1"));}
public SelenideElement getSearchInput(){
return $(By.xpath("//input[@placeholder=\"Szukaj\"]"));
}
public ElementsCollection getSearchResults(){
return $$(By.cssSelector("div a h2"));
}
public void assertUrl(){
String url = WebDriverRunner.url();
assertEquals(url,"https://cdaction.pl/");
}
public void assertTitle(){
String title = title();
assertEquals(title,"CD-Action Strona główna");
}
}

Binary file not shown.

View File

@ -0,0 +1 @@
com/mycompany/app/App.class

View File

@ -0,0 +1 @@
/home/tonywesoly/Code/Studia/testowanie/my-app/src/main/java/com/mycompany/app/App.java

View File

@ -0,0 +1 @@
com/mycompany/app/AppTest.class

View File

@ -0,0 +1,2 @@
/home/tonywesoly/Code/Studia/testowanie/my-app/src/test/java/com/mycompany/app/AppTestPage.java
/home/tonywesoly/Code/Studia/testowanie/my-app/src/test/java/com/mycompany/app/AppTest.java

View File

@ -0,0 +1,14 @@
# Created at 2024-02-11T15:47:21.085
System.exit() or native command error interrupted process checker.
java.lang.IllegalStateException: error [STOPPED] to read process 1449
at org.apache.maven.surefire.booter.PpidChecker.checkProcessInfo(PpidChecker.java:145)
at org.apache.maven.surefire.booter.PpidChecker.isProcessAlive(PpidChecker.java:124)
at org.apache.maven.surefire.booter.ForkedBooter$2.run(ForkedBooter.java:214)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: com.mycompany.app.AppTest
-------------------------------------------------------------------------------
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 114.494 s - in com.mycompany.app.AppTest

Binary file not shown.