Running tests now work, installed modules

This commit is contained in:
Xander 2025-04-02 16:36:50 +01:00
parent eb93d86b3e
commit c3c1d218d6
8 changed files with 99 additions and 23 deletions

11
.idea/libraries/assertj_core.xml generated Normal file
View file

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="assertj.core" type="repository">
<properties maven-id="org.assertj:assertj-core:4.0.0-M1" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/4.0.0-M1/assertj-core-4.0.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.17.1/byte-buddy-1.17.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

11
.idea/libraries/junit.xml generated Normal file
View file

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="junit" type="repository">
<properties maven-id="junit:junit:4.13.2" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.2/junit-4.13.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

17
.idea/libraries/junit_jupiter.xml generated Normal file
View file

@ -0,0 +1,17 @@
<component name="libraryTable">
<library name="junit.jupiter" type="repository">
<properties maven-id="org.junit.jupiter:junit-jupiter:5.10.0-M1" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.10.0-M1/junit-jupiter-5.10.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.10.0-M1/junit-jupiter-api-5.10.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.10.0-M1/junit-platform-commons-1.10.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.10.0-M1/junit-jupiter-params-5.10.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.10.0-M1/junit-jupiter-engine-5.10.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.10.0-M1/junit-platform-engine-1.10.0-M1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -0,0 +1,21 @@
<component name="libraryTable">
<library name="net.javacrumbs.json.unit.assertj" type="repository">
<properties maven-id="net.javacrumbs.json-unit:json-unit-assertj:3.0.0" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/javacrumbs/json-unit/json-unit-assertj/3.0.0/json-unit-assertj-3.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/javacrumbs/json-unit/json-unit-core/3.0.0/json-unit-core-3.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/3.24.2/assertj-core-3.24.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.12.21/byte-buddy-1.12.21.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/javacrumbs/json-unit/json-unit-json-path/3.0.0/json-unit-json-path-3.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/jayway/jsonpath/json-path/2.8.0/json-path-2.8.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/minidev/json-smart/2.4.10/json-smart-2.4.10.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/minidev/accessors-smart/2.4.9/accessors-smart-2.4.9.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm/9.3/asm-9.3.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -20,8 +20,9 @@
<jarDirectory url="file://$MODULE_DIR$/../../Selenium/selenium-java-4.28.1" recursive="false" type="SOURCES" /> <jarDirectory url="file://$MODULE_DIR$/../../Selenium/selenium-java-4.28.1" recursive="false" type="SOURCES" />
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="library" name="junit" level="project" />
<orderEntry type="library" name="junit.jupiter" level="project" /> <orderEntry type="library" name="junit.jupiter" level="project" />
<orderEntry type="library" name="assertj.core" level="project" /> <orderEntry type="library" name="assertj.core" level="project" />
<orderEntry type="library" name="net.javacrumbs.json.unit.assertj" level="project" />
<orderEntry type="library" name="junit" level="project" />
</component> </component>
</module> </module>

View file

@ -1,3 +1,5 @@
package main;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or //TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter. // click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main { public class Main {

34
src/test/testlogin.java Normal file
View file

@ -0,0 +1,34 @@
package test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class testlogin {
@Test
void testLogin() {
//begin chromedriver code
System.setProperty("webdriver.gecko.driver", "/usr/local/bin/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/bin/firefox"); // Explicitly set Firefox binary
WebDriver driver = new FirefoxDriver(options);
//end chromedriver code
driver.manage().window().maximize();
driver.get("https://practicetestautomation.com/practice-test-login/");
WebElement username = driver.findElement(By.id("username"));
WebElement password = driver.findElement(By.id("password"));
WebElement login = driver.findElement(By.id("submit"));
username.sendKeys("student");
password.sendKeys("Password123");
login.click();
String expectedUrl = "https://practicetestautomation.com/logged-in-successfully/";
assertEquals(expectedUrl, driver.getCurrentUrl());
driver.quit();
}
}

View file

@ -1,21 +0,0 @@
void testLogin() {
//begin chromedriver code
System.setProperty("webdriver.gecko.driver", "/usr/local/bin/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/bin/firefox"); // Explicitly set Firefox binary
WebDriver driver = new FirefoxDriver(options);
//end chromedriver code
driver.manage().window().maximize();
driver.get("https://practicetestautomation.com/practice-test-login/");
WebElement username = driver.findElement(By.id("username"));
WebElement password = driver.findElement(By.id("password"));
WebElement login = driver.findElement(By.id("submit"));
username.sendKeys("student");
password.sendKeys("Password123");
login.click();
String expectedUrl = "https://practicetestautomation.com/logged-in-successfully/";
assertEquals(expectedUrl, driver.getCurrentUrl());
driver.quit();
}