diff --git a/.github/wait-for-jenkins.sh b/.github/wait-for-jenkins.sh
new file mode 100644
index 0000000..d54211f
--- /dev/null
+++ b/.github/wait-for-jenkins.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+
+times=15
+while ! curl -sSL 'http://localhost:8080/login?from=%2F' 2>&1 \
+ | grep '/dev/null; do
+ echo 'Waiting for the Jenkins'
+ sleep 10
+ times=$(($times - 1))
+
+ if [ $times -le 0 ]; then
+ echo 'Time out'
+ exit 1
+ fi
+done
+
+echo 'The Jenkins is up'
\ No newline at end of file
diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml
new file mode 100644
index 0000000..6594114
--- /dev/null
+++ b/.github/workflows/cancel.yml
@@ -0,0 +1,16 @@
+name: Cancel
+
+on:
+ pull_request:
+ branches: [main]
+
+jobs:
+ cancel:
+ name: 'Cancel previous runs'
+ runs-on: ubuntu-latest
+ timeout-minutes: 3
+ steps:
+ - uses: styfle/cancel-workflow-action@0.9.0
+ with:
+ workflow_id: ci.yml
+ access_token: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..39db2bc
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,52 @@
+name: CI
+
+on:
+ pull_request:
+ branches: [main]
+
+jobs:
+ run-test:
+ name: 'Run tests'
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Git clone
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Install JDK
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'corretto'
+ java-version: '17'
+ cache: 'maven'
+
+ - name: Get list of changed files
+ run: echo "LIST_OF_CHANGED_FILES=$(git diff --name-only origin/$GITHUB_HEAD_REF $(git merge-base origin/$GITHUB_HEAD_REF origin/main) | tr '\n' ';')" >> $GITHUB_ENV
+
+ - name: Prepare Jenkins data
+ run: |
+ cat ${{ github.workspace }}/jenkins_data/jenkins_backup0* > ${{ github.workspace }}/jenkins_backup.tar
+ md5sum ${{ github.workspace }}/jenkins_backup.tar
+
+ - name: Extract Jenkins data and set permission
+ run: |
+ tar -xvf ./jenkins_backup.tar
+ chmod -R 777 ./jenkins_backup/var/jenkins_home
+
+ - name: Docker login
+ run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin
+
+ - name: Docker start
+ run: docker run --rm --detach -p 8080:8080 -v ${{ github.workspace }}/jenkins_backup/var/jenkins_home:/var/jenkins_home jenkins/jenkins:2.440.2-lts-jdk17
+
+ - name: Wait for the Jenkins
+ run: ./.github/wait-for-jenkins.sh
+
+ - name: Maven test
+ run: mvn test
+ env:
+ CHROME_OPTIONS: --remote-allow-origins=*;--disable-gpu;--no-sandbox;--disable-dev-shm-usage;--headless=new;--window-size=1920,1080
+ APP_OPTIONS: host=localhost;port=8080;admin.username=${{ secrets.ADMIN_USERNAME }};admin.password=${{ secrets.ADMIN_PASSWORD }}
+ CI_RUN: true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dcb672e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,43 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ 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
+
+### project ###
+local.properties
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e0f3358
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 RedRover.school
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..059f8c7
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# JenkinsQA_2024_spring
\ No newline at end of file
diff --git a/jenkins_data/jenkins_backup00 b/jenkins_data/jenkins_backup00
new file mode 100644
index 0000000..bbe7699
Binary files /dev/null and b/jenkins_data/jenkins_backup00 differ
diff --git a/jenkins_data/jenkins_backup01 b/jenkins_data/jenkins_backup01
new file mode 100644
index 0000000..0a737bb
Binary files /dev/null and b/jenkins_data/jenkins_backup01 differ
diff --git a/jenkins_data/jenkins_backup02 b/jenkins_data/jenkins_backup02
new file mode 100644
index 0000000..5aaee56
Binary files /dev/null and b/jenkins_data/jenkins_backup02 differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..81f6ed5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+
+ school.redrover
+ JenkinsQA_2024_spring
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+
+ UTF-8
+
+
+
+
+ org.testng
+ testng
+ 7.8.0
+
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 4.18.1
+
+
+
\ No newline at end of file
diff --git a/src/test/java/school/redrover/SmokeTest.java b/src/test/java/school/redrover/SmokeTest.java
new file mode 100644
index 0000000..cba1677
--- /dev/null
+++ b/src/test/java/school/redrover/SmokeTest.java
@@ -0,0 +1,18 @@
+package school.redrover;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+public class SmokeTest extends BaseTest {
+
+ @Test
+ public void testWelcome() {
+ WebElement welcomeText = getDriver().findElement(By.cssSelector(".empty-state-block > h1"));
+
+ Assert.assertEquals(welcomeText.getText(), "Welcome to Jenkins!");
+ }
+}
diff --git a/src/test/java/school/redrover/old/AqaGroupBaseTest.java b/src/test/java/school/redrover/old/AqaGroupBaseTest.java
new file mode 100644
index 0000000..211e989
--- /dev/null
+++ b/src/test/java/school/redrover/old/AqaGroupBaseTest.java
@@ -0,0 +1,69 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Ignore;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+@Ignore
+public abstract class AqaGroupBaseTest extends BaseTest {
+
+ private WebDriverWait wait5;
+ private WebDriverWait wait15;
+ private WebDriverWait wait25;
+ private WebDriverWait wait60;
+
+ @BeforeMethod
+ protected void beforeMethod() {
+ getDriver().manage().window().setSize(new Dimension(1920, 1080));
+ }
+
+ protected WebElement scrollIntoView(WebElement element) {
+ ((JavascriptExecutor) getDriver()).executeScript("arguments[0].scrollIntoView(true);", element);
+ return element;
+ }
+
+ protected WebDriverWait getWait(int seconds) {
+ return new WebDriverWait(getDriver(), Duration.ofSeconds(seconds));
+ }
+
+ protected WebDriverWait getWait5() {
+ if (wait5 == null) {
+ wait5 = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
+ }
+ return wait5;
+ }
+
+ protected WebDriverWait getWait15() {
+ if (wait15 == null) {
+ wait15 = new WebDriverWait(getDriver(), Duration.ofSeconds(15));
+ }
+ return wait15;
+ }
+
+ protected WebDriverWait getWait25() {
+ if (wait25 == null) {
+ wait25 = new WebDriverWait(getDriver(), Duration.ofSeconds(25));
+ }
+ return wait25;
+ }
+
+ protected WebDriverWait getWait60() {
+ if (wait60 == null) {
+ wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+ }
+ return wait60;
+ }
+
+ @AfterMethod
+ protected void afterMethod() {
+ wait5 = null;
+ wait15 = null;
+ wait25 = null;
+ wait60 = null;
+ }
+}
diff --git a/src/test/java/school/redrover/old/AqaGroupJenkinsTest.java b/src/test/java/school/redrover/old/AqaGroupJenkinsTest.java
new file mode 100644
index 0000000..4129afe
--- /dev/null
+++ b/src/test/java/school/redrover/old/AqaGroupJenkinsTest.java
@@ -0,0 +1,117 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class AqaGroupJenkinsTest extends AqaGroupBaseTest {
+
+ private void login() {
+ getDriver().get("http://localhost:8080/login");
+
+ getDriver().findElement(By.id("j_username")).sendKeys("admin");
+ getDriver().findElement(By.id("j_password")).sendKeys("admin");
+ getDriver().findElement(By.name("Submit")).click();
+ }
+
+ private void createItem(String name, String itemClassName) {
+ getDriver().findElement(By.cssSelector("#side-panel > div > div")).click();
+ getWait15().until(ExpectedConditions.presenceOfElementLocated(By.id("name"))).sendKeys(name);
+ getDriver().findElement(By.className(itemClassName)).click();
+ getDriver().findElement(By.id("ok-button")).click();
+ }
+
+ private void deleteItem(String name) {
+ if (!getDriver().findElements(By.cssSelector(String.format("a[href = 'job/%s/']", name))).isEmpty()) {
+ new Actions(getDriver())
+ .moveToElement(getDriver().findElement(
+ By.cssSelector(String.format("a[href = 'job/%s/']", name))))
+ .pause(1000)
+ .moveToElement(getDriver().findElement(
+ By.cssSelector(String.format("button[data-href = 'http://localhost:8080/job/%s/']", name))))
+ .click()
+ .perform();
+
+ getDriver().findElement(By.cssSelector(String.format("button[href='/job/%s/doDelete']", name))).click();
+ getDriver().findElement(By.className("jenkins-button--primary")).click();
+ }
+ }
+
+ private void returnToDashBoard() {
+ getDriver().findElement(By.cssSelector("a[href = '/']")).click();
+ }
+
+ @Test
+ public void testAuthJenkins() {
+ login();
+
+ Assert.assertTrue(getDriver().findElement(By.cssSelector("a[href = '/logout']")).isDisplayed());
+ }
+
+ @Test
+ public void testLogoutJenkins() {
+ login();
+
+ getDriver().findElement(By.cssSelector("a[href = '/logout']")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.tagName("h1")).getText(), "Sign in to Jenkins");
+ }
+
+ @Test
+ public void testNewItemJenkins() {
+ login();
+
+ deleteItem("FP");
+
+ createItem("FP", "hudson_model_FreeStyleProject");
+
+ returnToDashBoard();
+
+ Assert.assertTrue(getDriver().findElement(By.cssSelector("a[href = 'job/FP/']")).isDisplayed());
+ }
+
+ @Test
+ public void testCreateMultiConfigurationProject() {
+ login();
+
+ createItem("MCP", "hudson_matrix_MatrixProject");
+
+ returnToDashBoard();
+
+ Assert.assertTrue(getDriver().findElement(By.cssSelector("a[href = 'job/MCP/']")).isDisplayed());
+ }
+
+ @Test
+ public void testAddDescription() {
+ login();
+
+ deleteItem("MCP");
+
+ createItem("MCP", "hudson_matrix_MatrixProject");
+
+ getWait5().until(ExpectedConditions.presenceOfElementLocated(By.xpath("//textarea[@name = 'description']")));
+ getDriver().findElement(By.xpath("//textarea[@name = 'description']")).sendKeys("xxx");
+ getDriver().findElement(By.xpath("//button[@formnovalidate = 'formNoValidate']")).click();
+
+ Assert.assertTrue(getDriver().findElement(By.cssSelector("div#description")).getText().startsWith("xxx"));
+ }
+
+ @Test
+ public void testPeople() {
+ login();
+ getDriver().findElement(By.xpath("//a[@href='/asynchPeople/']")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//div[@class='jenkins-app-bar__content']")).getText(), "People");
+ }
+
+ @Test
+ public void testTitleJenkins() {
+ login();
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("div h1")).getText(), "Welcome to Jenkins!");
+ }
+}
diff --git a/src/test/java/school/redrover/old/AqaGroupTest.java b/src/test/java/school/redrover/old/AqaGroupTest.java
new file mode 100644
index 0000000..719651c
--- /dev/null
+++ b/src/test/java/school/redrover/old/AqaGroupTest.java
@@ -0,0 +1,1051 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.logging.LogEntries;
+import org.openqa.selenium.logging.LogEntry;
+import org.openqa.selenium.logging.LogType;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.*;
+
+import java.time.Duration;
+import java.util.List;
+
+@Ignore
+public class AqaGroupTest extends AqaGroupBaseTest {
+
+ private static final String URL = "https://demoqa.com/alerts";
+ private static final String BUTTONS_URL = "https://demoqa.com/buttons";
+ private static final String BROWSER_WINDOWS_URL = "https://demoqa.com/browser-windows";
+ private static final String BUTTONS_URL_ET = "https://testpages.eviltester.com/styled/dynamic-buttons-disabled.html";
+ private static final String ALERTS_URL = "https://testpages.eviltester.com/styled/alerts/alert-test.html";
+ private static final String FAKE_ALERTS_URL = "https://testpages.eviltester.com/styled/alerts/fake-alert-test.html";
+ private static final String ALERT_DISPLAYED = "fake alert box is displayed";
+ private static final By OPEN_MODAL_DIALOG_BUTTON = By.id("modaldialog");
+ private static final By MODAL_DIALOG_OK_BUTTON = By.id("dialog-ok");
+ private static final By MODAL_DIALOG_TEXT = By.id("dialog-text");
+ private static final String URL_LETCODE = "https://letcode.in/edit";
+ private static final String MODAL_WINDOW_URL = "https://tympanus.net/Development/ModalWindowEffects/";
+ private static final String URL_MOB = "http://23.105.246.172:5000/login";
+ private static final By EMAIL_INPUT = By.cssSelector("input.primaryInput");
+ private static final By LOGIN_BUTTON = By.className("authButton");
+ private static final By ERROR_MESSAGE = By.xpath("//*[contains(text(), 'Неправильный')]");
+
+ private String calc(String x) {
+ return String.valueOf(Math.log(Math.abs(12 * Math.sin(Integer.parseInt(x)))));
+ }
+
+
+ @Test
+ public void testAlert() {
+ getDriver().get(URL);
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(15000));
+
+ getDriver().findElement(By.id("alertButton")).click();
+ getDriver().switchTo().alert().accept();
+ Assert.assertTrue(
+ getDriver().findElement(By.id("alertButton")).isDisplayed(),
+ "alert is not accepted");
+ }
+
+ @Test
+ public void testWaitingAlert() {
+ getDriver().get(URL);
+
+ getDriver().findElement(By.id("timerAlertButton")).click();
+ Alert alert = getWait15().until(ExpectedConditions.alertIsPresent());
+ alert.accept();
+
+ Assert.assertTrue(
+ getDriver().findElement(By.id("timerAlertButton")).isDisplayed(),
+ "alert is not accepted");
+ }
+
+ @Test
+ public void testAcceptConfirmAlert() {
+ getDriver().get(URL);
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(15000));
+
+ scrollIntoView(getDriver().findElement(By.id("confirmButton"))).click();
+ getDriver().switchTo().alert().accept();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("confirmResult")).getText(),
+ "You selected Ok",
+ "alert is not accepted");
+ }
+
+ @Test
+ public void testDismissConfirmAlert() {
+ getDriver().get(URL);
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(15000));
+
+ scrollIntoView(getDriver().findElement(By.id("confirmButton"))).click();
+ getDriver().switchTo().alert().dismiss();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("confirmResult")).getText(),
+ "You selected Cancel",
+ "alert is not dismissed");
+ }
+
+ @Test
+ public void testPromptAlert() {
+ getDriver().get(URL);
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(15000));
+
+ scrollIntoView(getDriver().findElement(By.id("promtButton"))).click();
+ Alert alert = getDriver().switchTo().alert();
+ alert.sendKeys("Irina");
+ alert.accept();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("promptResult")).getText(),
+ "You entered Irina",
+ "unexpected result");
+ }
+
+ @Test
+ public void testCSSMediaQueriesSizing() {
+ getDriver().get("https://testpages.eviltester.com/styled/css-media-queries.html");
+
+ getDriver().manage().window().setSize(new Dimension(1220, 1080));
+
+ Assert.assertTrue(getWait15().until(ExpectedConditions.visibilityOfElementLocated(By.className("s1200"))).isDisplayed());
+ }
+
+ @Test
+ public void testCookieControlledAdmin() {
+ getDriver().get("https://testpages.eviltester.com/styled/cookies/adminview.html");
+
+ getDriver().findElement(By.id("username")).sendKeys("Admin");
+ getDriver().findElement(By.id("password")).sendKeys("AdminPass");
+ getDriver().findElement(By.id("login")).click();
+
+ Assert.assertEquals(getDriver().manage().getCookieNamed("loggedin").getValue(),
+ "Admin");
+
+ Assert.assertEquals(getDriver().findElement(By.id("adminh1")).getText(),
+ "Admin View");
+ }
+
+ @Test
+ public void testAdminLoginWithCookie() {
+ getDriver().get("https://testpages.eviltester.com");
+
+ getDriver().manage().addCookie(new Cookie("loggedin", "Admin"));
+
+ getDriver().get("https://testpages.eviltester.com/styled/cookies/adminview.html");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("adminh1")).getText(),
+ "Admin View");
+ }
+
+ @Test
+ public void testAdminLoginWithCookieAsSuperAdmin() {
+ getDriver().get("https://testpages.eviltester.com");
+
+ getDriver().manage().addCookie(new Cookie("loggedin", "Admin"));
+
+ getDriver().get("https://testpages.eviltester.com/styled/cookies/superadminview.html");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("adminh1")).getText(),
+ "Admin View");
+ }
+
+ @Test
+ public void testSuperAdminLoginWithCookieAsAdmin() {
+ getDriver().get("https://testpages.eviltester.com");
+
+ getDriver().manage().addCookie(new Cookie("loggedin", "SuperAdmin"));
+
+ getDriver().get("https://testpages.eviltester.com/styled/cookies/adminview.html");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("adminh1")).getText(),
+ "Admin View");
+ }
+
+ @Test
+ public void testSuperAdminLoginWithCookie() {
+ getDriver().get("https://testpages.eviltester.com");
+
+ getDriver().manage().addCookie(new Cookie("loggedin", "SuperAdmin"));
+
+ getDriver().get("https://testpages.eviltester.com/styled/cookies/superadminview.html");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("superadminh1")).getText(),
+ "Super Admin View");
+ }
+
+ @Test
+ public void testDoubleClickButton() {
+ getDriver().get(BUTTONS_URL);
+
+ new Actions(getDriver())
+ .doubleClick(scrollIntoView(getDriver().findElement(By.id("doubleClickBtn"))))
+ .perform();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("doubleClickMessage")).getText(),
+ "You have done a double click",
+ "Double click attempt failed.");
+ }
+
+ @Test
+ public void testRightClickButton() {
+ getDriver().get(BUTTONS_URL);
+
+ new Actions(getDriver())
+ .contextClick(scrollIntoView(getDriver().findElement(By.id("rightClickBtn"))))
+ .perform();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("rightClickMessage")).getText(),
+ "You have done a right click",
+ "Right click attempt failed.");
+ }
+
+ @Test
+ public void testDynamicClickButton() {
+ getDriver().get(BUTTONS_URL);
+
+ scrollIntoView(getDriver().findElement(By.xpath("//*[@id='rightClickBtn']/../following-sibling::div/button")))
+ .click();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("dynamicClickMessage")).getText(),
+ "You have done a dynamic click",
+ "Right click attempt failed.");
+ }
+
+ @DataProvider(name = "windowDataProvider")
+ public Object[][] windowDataProvider() {
+ return new Object[][]{{"tabButton"}, {"windowButton"}};
+ }
+
+ @Test(dataProvider = "windowDataProvider")
+ public void testBrowserWindowOpen(String buttonId) {
+ getDriver().get(BROWSER_WINDOWS_URL);
+
+ getWait5().until(ExpectedConditions.elementToBeClickable(By.id(buttonId))).click();
+
+ getWait5().until(ExpectedConditions.numberOfWindowsToBe(2));
+
+ String original = getDriver().getWindowHandle();
+ for (String handle : getDriver().getWindowHandles()) {
+ if (!handle.equals(original)) {
+ getDriver().switchTo().window(handle);
+ break;
+ }
+ }
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("sampleHeading")).getText(),
+ "This is a sample page");
+ }
+
+ @Test
+ public void testRadioButton() {
+ getDriver().get("https://demoqa.com/radio-button");
+
+ getDriver().findElement(By.xpath("//*[@for='impressiveRadio']")).click();
+
+ Assert.assertTrue(
+ getDriver().findElement(By.className("text-success")).isDisplayed(),
+ "radiobutton is not selected");
+ }
+
+ @Test
+ public void testPracticeFillForm() {
+ getDriver().get("https://demoqa.com/automation-practice-form");
+
+ scrollIntoView(getDriver().findElement(By.id("firstName"))).sendKeys("Irina");
+ scrollIntoView(getDriver().findElement(By.id("lastName"))).sendKeys("Kuperman");
+ scrollIntoView(getDriver().findElement(By.id("userEmail"))).sendKeys("ama@ama.com");
+ scrollIntoView(getDriver().findElement(By.cssSelector("[for='gender-radio-2'"))).click();
+ scrollIntoView(getDriver().findElement(By.id("userNumber"))).sendKeys("1234567890");
+
+ scrollIntoView(getDriver().findElement(By.id("submit"))).click();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("example-modal-sizes-title-lg")).getText(),
+ "Thanks for submitting the form");
+ }
+
+ @Test
+ public void test2GetTextLinks() {
+ getDriver().get("https://demoqa.com/links");
+
+ scrollIntoView(getDriver().findElement(By.id("no-content"))).click();
+
+ WebElement link = getWait15().until(ExpectedConditions.visibilityOfElementLocated(By.id("linkResponse")));
+
+ Assert.assertEquals(
+ link.getText(),
+ "Link has responded with staus 204 and status text No Content",
+ "wrong answer");
+ }
+
+ @Test
+ public void testSimpleDynamicButtons() {
+ getDriver().get("https://testpages.eviltester.com/styled/dynamic-buttons-simple.html");
+
+ getDriver().findElement(By.id("button00")).click();
+ getDriver().findElement(By.id("button01")).click();
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.id("button02")));
+ getDriver().findElement(By.id("button02")).click();
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.id("button03")));
+ getDriver().findElement(By.id("button03")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.id("buttonmessage")).getText(), "All Buttons Clicked", "Not All Buttons Clicked");
+ }
+
+ @Test
+ public void testXHTTPMessages() {
+ getDriver().get("https://testpages.eviltester.com/styled/sync/xhttp-messages.html");
+
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+ wait.until(ExpectedConditions.textToBePresentInElement(getDriver().findElement(By.id("messagesstatus")), "Message Count: 0 : 0"));
+
+ Assert.assertEquals(getDriver().findElement(By.id("messagesstatus")).getText(), "Message Count: 0 : 0", "message count is not zero");
+ }
+
+ @Test
+ public void testDisabledDynamicButtons() {
+ getDriver().get(BUTTONS_URL_ET);
+
+ getWait15().until(ExpectedConditions.elementToBeClickable(By.id("button00"))).click();
+ getWait15().until(ExpectedConditions.elementToBeClickable(By.id("button01"))).click();
+ getWait15().until(ExpectedConditions.elementToBeClickable(By.id("button02"))).click();
+ getWait15().until(ExpectedConditions.elementToBeClickable(By.id("button03"))).click();
+
+ Boolean found = getWait15().until(ExpectedConditions.textToBePresentInElementLocated(By.id("buttonmessage"),
+ "All Buttons Clicked"));
+ Assert.assertTrue(found, "Text \"All Buttons Clicked\" not found");
+ }
+
+ @DataProvider(name = "alertDataProvider")
+ public Object[][] alertDataProvider() {
+ return new Object[][]{
+ {"alertexamples", "alertexplanation", "You triggered and handled the alert dialog", null, true},
+ {"confirmexample", "confirmexplanation", "You clicked OK, confirm returned true.", null, true},
+ {"confirmexample", "confirmexplanation", "You clicked Cancel, confirm returned false.", null, false},
+ {"promptexample", "promptexplanation", "You clicked OK. 'prompt' returned some random input", "some random input", true},
+ {"promptexample", "promptexplanation", "You clicked Cancel. 'prompt' returned null", "some random input", false}
+ };
+ }
+
+ @Test(dataProvider = "alertDataProvider")
+ public void testAlerts(String buttonId, String messageId, String expected, String keys, boolean accept) {
+ getDriver().get(ALERTS_URL);
+
+ getDriver().findElement(By.id(buttonId)).click();
+
+ Alert alert = getWait15().until(ExpectedConditions.alertIsPresent());
+
+ if (keys != null) {
+ alert.sendKeys(keys);
+ }
+
+ if (accept) {
+ alert.accept();
+ } else {
+ alert.dismiss();
+ }
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id(messageId)).getText(),
+ expected);
+ }
+
+ @Test
+ public void testExpandingDivWithClickableLink() {
+ getDriver().get("https://testpages.eviltester.com/styled/expandingdiv.html");
+
+ new Actions(getDriver())
+ .moveToElement(getDriver().findElement(By.className("expand")))
+ .pause(500)
+ .moveToElement(getDriver().findElement(By.cssSelector(".expand p a")))
+ .click()
+ .pause(500)
+ .perform();
+
+ Assert.assertTrue(getDriver().getCurrentUrl().contains("expandeddiv"), "Unexpected URL.");
+ }
+
+ @DataProvider(name = "fakeAlertDataProvider")
+ public Object[][] fakeAlertDataProvider() {
+ return new Object[][]{
+ {By.id("fakealert"), MODAL_DIALOG_OK_BUTTON},
+ {OPEN_MODAL_DIALOG_BUTTON, MODAL_DIALOG_OK_BUTTON}
+ };
+ }
+
+ @Test(dataProvider = "fakeAlertDataProvider")
+ public void testFakeAlertCloseByClickOnOkButton(By triggerAlertButton, By okAlertButton) {
+ getDriver().get(FAKE_ALERTS_URL);
+
+ getDriver().findElement(triggerAlertButton).click();
+
+ WebElement message = getDriver().findElement(By.id("dialog-text"));
+
+ getDriver().findElement(okAlertButton).click();
+
+ Assert.assertFalse(message.isDisplayed(), ALERT_DISPLAYED);
+ }
+
+ @DataProvider(name = "fakeAlertKeysProvider")
+ public Object[][] fakeAlertKeysProvider() {
+ return new Object[][]{{Keys.ENTER}, {Keys.ESCAPE}};
+ }
+
+ @Test(dataProvider = "fakeAlertKeysProvider")
+ public void testFakeModalAlertCloseBySendKeyToOkAlertButton(Keys key) {
+ getDriver().get(FAKE_ALERTS_URL);
+
+ getDriver().findElement(OPEN_MODAL_DIALOG_BUTTON).click();
+
+ WebElement message = getDriver().findElement(MODAL_DIALOG_TEXT);
+
+ getDriver().findElement(MODAL_DIALOG_OK_BUTTON).sendKeys(key);
+
+ Assert.assertFalse(message.isDisplayed(), ALERT_DISPLAYED);
+ }
+
+ @Test
+ public void testFakeModalAlertCloseByJsDispatchEventToDocument() {
+ getDriver().get(FAKE_ALERTS_URL);
+
+ getDriver().findElement(OPEN_MODAL_DIALOG_BUTTON).click();
+
+ WebElement message = getDriver().findElement(MODAL_DIALOG_TEXT);
+
+ ((JavascriptExecutor) getDriver()).executeScript(
+ "document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Esc'}));");
+
+ Assert.assertFalse(message.isDisplayed(), ALERT_DISPLAYED);
+ }
+
+ @Test
+ public void testFakeModalAlertCloseByJsClickOnBackground() {
+ getDriver().get(FAKE_ALERTS_URL);
+
+ getDriver().findElement(OPEN_MODAL_DIALOG_BUTTON).click();
+
+ WebElement message = getDriver().findElement(MODAL_DIALOG_TEXT);
+
+ ((JavascriptExecutor) getDriver()).executeScript(
+ "arguments[0].click();",
+ getDriver().findElement(By.cssSelector(".faded-background.active")));
+
+ Assert.assertFalse(message.isDisplayed(), ALERT_DISPLAYED);
+ }
+
+ @Test
+ public void testFakeModalAlertCloseByMoveToLocationAndClickOnBackground() {
+ getDriver().get(FAKE_ALERTS_URL);
+
+ getDriver().findElement(OPEN_MODAL_DIALOG_BUTTON).click();
+
+ WebElement message = getDriver().findElement(MODAL_DIALOG_TEXT);
+
+ new Actions(getDriver())
+ .moveToLocation(0, 0)
+ .click()
+ .perform();
+
+ Assert.assertFalse(message.isDisplayed(), ALERT_DISPLAYED);
+ }
+
+ @Test
+ public void testBasicAuthorization() {
+ getDriver().get("https://authorized:password001@testpages.eviltester.com/styled/auth/basic-auth-results.html");
+ Assert.assertEquals(
+ getDriver().findElement(By.id("status")).getText(),
+ "Authenticated");
+ }
+
+ @Test
+ public void testHiddenElement() {
+ getDriver().get("https://the-internet.herokuapp.com/dynamic_loading/1");
+
+ getDriver().findElement(By.tagName("button")).click();
+ getWait5().until(ExpectedConditions.visibilityOfElementLocated(By.id("finish")));
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("finish")).getText(),
+ "Hello World!",
+ "error");
+ }
+
+ @Test
+ public void testRenderedElement() {
+ getDriver().get("https://the-internet.herokuapp.com/dynamic_loading/2");
+
+ getDriver().findElement(By.tagName("button")).click();
+ getWait5().until(ExpectedConditions.presenceOfElementLocated(By.id("finish")));
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("finish")).getText(),
+ "Hello World!",
+ "error");
+ }
+
+ @Test
+ public void testAddElement() {
+ getDriver().get("https://the-internet.herokuapp.com/add_remove_elements/");
+
+ getDriver().findElement(By.cssSelector(".example button")).click();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.className("added-manually")).getText(),
+ "Delete",
+ "not added delete");
+ }
+
+ @Test
+ public void testDeleteElement() {
+ getDriver().get("https://the-internet.herokuapp.com/add_remove_elements/");
+
+ getDriver().findElement(By.cssSelector(".example button")).click();
+ getDriver().findElement(By.cssSelector(".example button")).click();
+ getDriver().findElement(By.className("added-manually")).click();
+ getDriver().findElement(By.className("added-manually")).click();
+
+ Assert.assertTrue(
+ getDriver().findElements(By.className("added-manually")).isEmpty(),
+ "delete(s) present");
+ }
+
+ @Test
+ public void testAuth() {
+ getDriver().get("http://admin:admin@the-internet.herokuapp.com/basic_auth");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.tagName("p")).getText(),
+ "Congratulations! You must have the proper credentials.");
+ }
+
+ @Test(expectedExceptions = AssertionError.class)
+ public void testFindBrokenPic() {
+ getDriver().get("https://the-internet.herokuapp.com/broken_images");
+
+ List lst = getDriver().findElements(By.xpath("//*[@class ='example']/img"));
+
+ Assert.assertFalse(lst.isEmpty());
+
+ for (WebElement pic : lst) {
+ Assert.assertNotEquals(
+ pic.getDomProperty("naturalWidth"),
+ "0",
+ "broken image is detected");
+ }
+ }
+
+ @Test
+ public void testCheckBox() {
+ getDriver().get("https://the-internet.herokuapp.com/checkboxes");
+
+ WebElement checkBox1 = getDriver().findElement(By.xpath("//*[@type = 'checkbox']"));
+ WebElement checkBox2 = getDriver().findElement(By.xpath("//*[@type = 'checkbox'][2]"));
+ checkBox1.click();
+ checkBox2.click();
+
+ Assert.assertTrue(
+ checkBox1.isSelected(),
+ "checkbox 1 is not checked");
+ Assert.assertFalse(
+ checkBox2.isSelected(),
+ "checkbox 2 is checked");
+ }
+
+ @Test(expectedExceptions = AssertionError.class)
+ public void testFindBrokenPicTestFinal() {
+ getDriver().get("https://the-internet.herokuapp.com/broken_images");
+
+ LogEntries logs = getDriver().manage().logs().get(LogType.BROWSER);
+
+ Assert.assertFalse(logs.getAll().isEmpty());
+
+ for (LogEntry entry : logs) {
+ Assert.assertTrue(
+ entry.getMessage().contains("Failed to load resource: the server responded with a status of 404"),
+ "broken image is detected");
+ }
+ }
+
+ @Test
+ public void testDragAndDrop() {
+ getDriver().get("https://testpages.eviltester.com/styled/drag-drop-javascript.html");
+
+ WebElement dragMe1 = getDriver().findElement(By.id("draggable1"));
+ WebElement dropHere1 = getDriver().findElement(By.id("droppable1"));
+
+ Actions actions = new Actions(getDriver());
+ actions
+ .dragAndDrop(dragMe1, dropHere1)
+ .build()
+ .perform();
+
+ Assert.assertEquals(
+ dropHere1.getText(),
+ "Dropped!",
+ "error");
+ }
+
+ @Test
+ public void testDragAndDropBoth() {
+ getDriver().get("https://testpages.eviltester.com/styled/drag-drop-javascript.html");
+
+ WebElement dragMe1 = getDriver().findElement(By.id("draggable1"));
+ WebElement dragMe2 = getDriver().findElement(By.id("draggable2"));
+ WebElement dropHere1 = getDriver().findElement(By.id("droppable1"));
+
+ Actions actions = new Actions(getDriver());
+ actions
+ .dragAndDrop(dragMe1, dropHere1)
+ .build()
+ .perform();
+
+ actions
+ .dragAndDrop(dragMe2, dropHere1)
+ .build()
+ .perform();
+
+ Assert.assertEquals(
+ dropHere1.getText(),
+ "Get Off Me!",
+ "error");
+ }
+
+ @Test
+ public void testRedirectSlow() {
+ getDriver().get("https://testpages.eviltester.com/styled/javascript-redirect-test.html");
+
+ getDriver().findElement(By.id("delaygotobasic")).click();
+ getWait15().until(ExpectedConditions.urlContains("redirected"));
+
+ Assert.assertEquals(
+ getDriver().findElement(By.className("explanation")).getText(),
+ "You have been successfully redirected.");
+ }
+
+ @Test
+ public void testRedirectFast() {
+ getDriver().get("https://testpages.eviltester.com/styled/javascript-redirect-test.html");
+
+ getDriver().findElement(By.id("delaygotobounce")).click();
+ getWait15().until(ExpectedConditions.urlContains("redirected"));
+
+ Assert.assertEquals(
+ getDriver().findElement(By.className("explanation")).getText(),
+ "You have been successfully redirected.");
+ }
+
+ @Test
+ public void testBasicAjax() {
+ getDriver().get("https://testpages.eviltester.com/styled/basic-ajax-test.html");
+
+ Select category = new Select(getDriver().findElement(By.id("combo1")));
+ category.selectByValue("2");
+
+ getWait15().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("[value='10']")));
+
+ Select language = new Select(getDriver().findElement(By.id("combo2")));
+ language.selectByValue("11");
+
+ getDriver().findElement(By.className("styled-click-button")).click();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("_valueid")).getText(), "2");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("_valuelanguage_id")).getText(), "11");
+ }
+
+ @Test
+ public void testKeysEventDisplay() {
+ getDriver().get("https://testpages.eviltester.com/styled/key-click-display-test.html");
+
+ getDriver().findElement(By.id("button")).sendKeys("a");
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("event1")).getText(),
+ "down a 65");
+ }
+
+ @Test
+ public void testSendKeys() {
+ getDriver().get(URL_LETCODE);
+ getDriver().findElement(By.id("fullName")).sendKeys("Ira");
+ Assert.assertEquals(
+ getDriver().findElement(By.id("fullName")).getAttribute("value"),
+ "Ira");
+ }
+
+ @Test
+ public void testKeyboardTAB() {
+ getDriver().get(URL_LETCODE);
+ getDriver().findElement(By.id("join")).sendKeys(" at all" + Keys.TAB);
+// getDriver().findElement(By.id("join")).sendKeys(" at all\t");
+ Assert.assertEquals(
+ getDriver().switchTo().activeElement().getAttribute("value"),
+ "ortonikc");
+ }
+
+ @Test
+ public void testClear() {
+ getDriver().get(URL_LETCODE);
+ getDriver().findElement(By.id("clearMe")).clear();
+ Assert.assertEquals(
+ getDriver().findElement(By.id("clearMe")).getAttribute("value"),
+ "");
+ }
+
+ @Test
+ public void testIsEnabled() {
+ getDriver().get(URL_LETCODE);
+ Assert.assertFalse(getDriver().findElement(By.id("noEdit")).isEnabled());
+ }
+
+ @Test
+ public void testReadonly() {
+ getDriver().get(URL_LETCODE);
+ Assert.assertEquals(
+ getDriver().findElement(By.id("dontwrite")).getAttribute("readonly"),
+ "true");
+ }
+
+ @Test
+ public void testHugeForm() {
+ getDriver().get("https://suninjuly.github.io/huge_form.html");
+
+ List elements = getDriver().findElements(By.tagName("input"));
+ for (WebElement item : elements) {
+ item.sendKeys("Мой ответ");
+ }
+
+ getDriver().findElement(By.cssSelector("button.btn")).click();
+
+ Assert.assertTrue(
+ getWait15()
+ .until(ExpectedConditions.alertIsPresent())
+ .getText()
+ .startsWith("Congrats, you've passed the task!"),
+ "You shall not pass");
+ }
+
+ @Test
+ public void testTextToBePresent() {
+ getDriver().get("https://suninjuly.github.io/explicit_wait2.html");
+
+ WebElement button_book = getDriver().findElement(By.id("book"));
+ getWait15().until(ExpectedConditions.textToBePresentInElementLocated(By.id("price"), "$100"));
+ button_book.click();
+
+ getDriver().findElement(By.id("answer")).sendKeys(calc(getDriver().findElement(By.id("input_value")).getText()));
+ getDriver().findElement(By.id("solve")).click();
+
+ Assert.assertTrue(
+ getWait15()
+ .until(ExpectedConditions.alertIsPresent())
+ .getText()
+ .startsWith("Congrats, you've passed the task!"),
+ "You shall not pass");
+ }
+
+ @Test
+ public void testClientSideDelay() {
+ getDriver().get("http://uitestingplayground.com/clientdelay");
+
+ getWait25().until(ExpectedConditions.elementToBeClickable(By.id("ajaxButton"))).click();
+
+ Assert.assertTrue(
+ getWait25()
+ .until(ExpectedConditions.visibilityOfElementLocated(By.className("bg-success")))
+ .getText()
+ .startsWith("Data calculated"),
+ "Label text wrong");
+ }
+
+ @Test
+ public void testOverlappedElement() {
+ getDriver().get("http://uitestingplayground.com/overlapped");
+
+ final String myName = "myName";
+ WebElement name = scrollIntoView(getDriver().findElement(By.id("name")));
+ name.sendKeys(myName);
+
+ Assert.assertEquals(
+ name.getAttribute("value"),
+ myName,
+ "input field contains wrong value");
+ }
+
+ @Test
+ public void testHoverParagraph() {
+ getDriver().get("https://testpages.eviltester.com/styled/csspseudo/css-hover.html");
+
+ new Actions(getDriver())
+ .moveToElement(getDriver().findElement(By.id("hoverpara")))
+ .perform();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("hoverparaeffect")).getText(),
+ "You can see this paragraph now that you hovered on the above 'button'.");
+ }
+
+ @Test
+ public void testModalWindow() {
+ getDriver().get(MODAL_WINDOW_URL);
+
+ getDriver().findElement(By.cssSelector("[data-modal = 'modal-1']")).click();
+ getDriver().findElement(By.className("md-close")).click();
+
+ Assert.assertTrue(getDriver().findElement(By.cssSelector("[data-modal = 'modal-1']")).isEnabled());
+ }
+
+ @Test
+ public void testDragDrop() {
+ getDriver().get("https://testpages.eviltester.com/styled/drag-drop-javascript.html");
+
+ WebElement draggable = getDriver().findElement(By.id("draggable1"));
+ WebElement droppable = getDriver().findElement(By.id("droppable1"));
+
+ new Actions(getDriver())
+ .dragAndDrop(draggable, droppable)
+ .perform();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("droppable1")).getText(),
+ "Dropped!",
+ "Не удалось перетащить элемент");
+ }
+
+ @Test
+ public void testRefreshPage() {
+ getDriver().get("https://testpages.eviltester.com/styled/refresh");
+
+ String text = getDriver().findElement(By.id("embeddedrefreshdatevalue")).getText();
+ new Actions(getDriver()).pause(1000).perform();
+ getDriver().findElement(By.id("button")).click();
+
+ Assert.assertNotEquals(
+ getDriver().findElement(By.id("embeddedrefreshdatevalue")).getText(),
+ text);
+ }
+
+ @Test
+ public void testHoverDiv() {
+ getDriver().get("https://testpages.eviltester.com/styled/csspseudo/css-hover.html");
+
+ new Actions(getDriver())
+ .moveToElement(getDriver().findElement(By.id("hoverdivpara")))
+ .perform();
+
+ Assert.assertEquals(
+ getDriver().findElement(By.id("hoverdivparaeffect")).getText(),
+ "You can see this child div content now that you hovered on the above 'button'.");
+ }
+
+ @DataProvider(name = "modalWindowsDataProvider")
+ public Object[][] modalWindowsDataProvider() {
+ return new Object[][]{
+ {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10},
+ {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}
+ };
+ }
+
+ @Test(dataProvider = "modalWindowsDataProvider")
+ public void testModalWindowsClose(int windowNumber) {
+ getDriver().get(MODAL_WINDOW_URL);
+
+ getDriver().findElement(By.cssSelector("[data-modal = 'modal-" + windowNumber + "']")).click();
+
+ getWait5().until(ExpectedConditions.elementToBeClickable(By.cssSelector(".md-show .md-close")));
+
+ new Actions(getDriver())
+ .moveToLocation(0, 0)
+ .click()
+ .perform();
+
+ Assert.assertTrue(
+ getWait5().until(ExpectedConditions.invisibilityOfElementLocated(By.className("md-content"))));
+ }
+
+ @Test
+ public void testIsEnabled2() {
+ getDriver().get(URL_LETCODE);
+
+ Assert.assertTrue(getDriver().findElement(By.id("dontwrite")).isEnabled());
+ }
+
+ @Test
+ public void testButtonChangeItsName() {
+ getDriver().get("http://uitestingplayground.com/textinput");
+
+ getDriver().findElement(By.id("newButtonName")).sendKeys("carolync");
+ getDriver().findElement(By.id("updatingButton")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.id("updatingButton")).getText(), "carolync");
+ }
+
+ @Test
+ public void testWaitUntilPageLoad() {
+ getDriver().get("http://uitestingplayground.com/home");
+
+ getDriver().findElement(By.xpath("//*[contains(text(), 'Load Delay')]")).click();
+ Assert.assertTrue(getWait60().until(ExpectedConditions.urlContains("http://uitestingplayground.com/loaddelay")), "Error of redirection!");
+ }
+
+ @Test
+ public void testHiddenButtons() {
+ getDriver().get("http://uitestingplayground.com/visibility");
+
+ String xpath = "//button[@id='removedButton' or @id='zeroWidthButton' or @id='overlappedButton' or @id='transparentButton'" +
+ " or @id='invisibleButton' or @id='notdisplayedButton' or @id='offscreenButton']";
+
+ getDriver().findElement(By.id("hideButton")).click();
+
+ Assert.assertFalse(getDriver().findElement(By.xpath(xpath)).isDisplayed(), "Not all the buttons are hidden!");
+ }
+
+ @Test
+ public void testRemovesPassword() {
+ getDriver().get(URL_MOB);
+
+ getWait15().until(ExpectedConditions.visibilityOfElementLocated(EMAIL_INPUT)).sendKeys("yyyyyyyyyy@mail.xx");
+ getDriver().findElement(LOGIN_BUTTON).click();
+
+ Assert.assertEquals(getWait15().until(ExpectedConditions.presenceOfElementLocated(ERROR_MESSAGE)).getText(), "Неправильный логин или пароль");
+ }
+
+ @DataProvider(name = "visibilityDataProvider")
+ public Object[][] visibilityDataProvider() {
+ return new Object[][]{
+ {By.id("removedButton")}, {By.id("zeroWidthButton")}, {By.id("Overlapped")},
+ {By.id("transparentButton")}, {By.id("invisibleButton")}, {By.id("notdisplayedButton")},
+ {By.id("offscreenButton")}
+ };
+ }
+
+ @Test(dataProvider = "visibilityDataProvider")
+ public void testVisibility(By locator) {
+ getDriver().get("http://uitestingplayground.com/visibility");
+
+ getDriver().findElement(By.id("hideButton")).click();
+
+ Assert.assertTrue(getWait5().until(ExpectedConditions.invisibilityOfElementLocated(locator)));
+ }
+
+ @Parameters({"user_role", "isActive"})
+ @Test
+ public void testUserRole(@Optional("Admin") String role, @Optional("true") Boolean isActive) {
+ Assert.assertTrue(role.equals("Admin") && isActive);
+ }
+
+ @Test
+ public void testOpenCloseAlertPopUp() {
+ getDriver().get("http://uitestingplayground.com/classattr");
+
+ String blueButtonXpath = "//button[contains(concat(' ', (@class), ' '),' btn-primary ')]";
+ getDriver().findElement(By.xpath(blueButtonXpath)).click();
+ getWait5().until(ExpectedConditions.alertIsPresent()).accept();
+
+ Assert.assertTrue(getWait5().until(ExpectedConditions.elementToBeClickable(By
+ .xpath(blueButtonXpath))).isEnabled(),
+ "Alert hasn't been closed!");
+ }
+
+ @Test
+ public void testScrollToFindButton() {
+ getDriver().get("http://uitestingplayground.com/scrollbars");
+
+ Assert.assertTrue(scrollIntoView(getDriver().findElement(By.id("hidingButton"))).isEnabled());
+ }
+
+ @Test
+ public void testDoubleClickAtFakeLink() {
+ getDriver().get("http://uitestingplayground.com/mouseover");
+
+ new Actions(getDriver()).moveToElement(getDriver().findElement(By.linkText("Click me"))).doubleClick().build().perform();
+
+ Assert.assertEquals(getDriver().findElement(By.id("clickCount")).getText(), "2",
+ "Double click doesn't work!");
+ }
+
+ @Test
+ public void testSuccessfulLogin() {
+ getDriver().get("http://uitestingplayground.com/sampleapp");
+
+ String login = "carolync";
+
+ getDriver().findElement(By.xpath("//input[@name='UserName']")).sendKeys(login);
+ getDriver().findElement(By.xpath("//input[@name='Password']")).sendKeys("pwd");
+ getDriver().findElement(By.id("login")).click();
+
+ Assert.assertTrue(getWait5().until(ExpectedConditions.textToBePresentInElementLocated(By.id("loginstatus"),
+ "Welcome, " + login)), "Unsuccessful login attempt!");
+ }
+
+ @Test
+ public void testGetValFromDynamicTable() {
+ getDriver().get("http://uitestingplayground.com/dynamictable");
+
+ String cpuValueRegEX = "^.* ([\\d.]+%).*";
+ String rowChrome = getDriver().findElement(By.xpath("//span[text()= 'Chrome']/..")).getText();
+ String cpuValue = rowChrome.replaceAll(cpuValueRegEX, "$1");
+ String warningValue = getDriver().findElement(By.className("bg-warning")).getText().replaceAll(cpuValueRegEX, "$1");
+
+ Assert.assertEquals(cpuValue, warningValue, "CPU values aren't equivalents!");
+ }
+
+ @Test
+ public void testNonBreakingSpace() {
+ getDriver().get("http://uitestingplayground.com/nbsp");
+
+ Assert.assertTrue(getDriver().findElement(By.xpath("//*[text() = 'My Button']")).isEnabled());
+ }
+
+ @Test
+ public void testWaitForElement() {
+ getDriver().get("http://uitestingplayground.com/clientdelay");
+
+ getDriver().findElement(By.id("ajaxButton")).click();
+
+ Assert.assertTrue(
+ getWait25().until(ExpectedConditions.textToBePresentInElementLocated(
+ By.id("content"),
+ "Data calculated on the client side.")));
+ }
+
+ @Test
+ public void testWaitForElement2() {
+ getDriver().get("http://uitestingplayground.com/clientdelay");
+
+ getDriver().findElement(By.id("ajaxButton")).click();
+
+ WebElement a = getWait25().until(ExpectedConditions.presenceOfElementLocated(By.className("bg-success")));
+
+ Assert.assertEquals(a.getText(), "Data calculated on the client side.");
+ }
+
+ @Test
+ public void testWaitForElement3() {
+ getDriver().get("http://uitestingplayground.com/clientdelay");
+
+ getDriver().findElement(By.id("ajaxButton")).click();
+
+ WebElement a = getWait25().until(ExpectedConditions.visibilityOfElementLocated(By.className("bg-success")));
+
+ Assert.assertEquals(a.getText(), "Data calculated on the client side.");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/ArMobileTest.java b/src/test/java/school/redrover/old/ArMobileTest.java
new file mode 100644
index 0000000..0f1d790
--- /dev/null
+++ b/src/test/java/school/redrover/old/ArMobileTest.java
@@ -0,0 +1,235 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+
+@Ignore
+public class ArMobileTest extends BaseTest {
+
+ private static final String URL = "http://23.105.246.172:5000/login";
+ private static final String INPUT_PASSWORD = "//input[@class='ant-input']";
+ private static final String INPUT_EMAIL = "//input[@class='ant-input primaryInput not-entered']";
+ private static final String BTN_PASSWORD = "//button[@class='ant-btn ant-btn-default authButton big colorPrimary ']";
+ private static final String EMAIL = "f.ff.1980@list.ru";
+ private static final String PASSWORD = "012345678";
+
+ private static final By GET_PASWORD = By.xpath("//h2[@class='ant-typography h2_m RestorePassword__sendSuccess-text'][contains(.,'Мы отправили по адресу')]");
+ private static final By GET_EMAIL = By.xpath("//div[@class='ant-typography p_r RestorePassword__form-userNotFound']");
+ private static final By GET_ERROR = By.xpath("//div[@style='text-align: center; margin-bottom: 20px; color: rgb(255, 0, 0);']");
+ private static final By NEW_PROGECT_TEXT = By.xpath("//div[@class='Sidebar__project-name'][contains(.,'1Новый проект')]");
+ private static final By GET_POLITICA = By.xpath("//h1[@class='page-header-title clr']");
+ private static final By GET_POLITICA_USER = By.xpath("//span[@style='font-size: 19px;'][contains(.,'Предмет пользовательского соглашения')]");
+ private static final By GET_BOT = By.xpath("//span[@dir='auto']");
+
+ private void openBrowser() {
+ getDriver().get(URL);
+ getDriver().manage().window().setSize(new Dimension(1920, 1080));
+ getDriver().manage().timeouts().pageLoadTimeout(25, TimeUnit.SECONDS);
+ getDriver().manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
+ }
+
+ private void loginJenkins() {
+ getDriver().get("http://localhost:8080/login");
+ getDriver().findElement(By.id("j_username")).sendKeys("admin");
+ getDriver().findElement(By.id("j_password")).sendKeys("admin");
+ getDriver().findElement(By.name("Submit")).click();
+ }
+
+ private void login() {
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).sendKeys(EMAIL);
+ getDriver().findElement(By.xpath(INPUT_PASSWORD)).sendKeys(PASSWORD);
+ getDriver().findElement(By.xpath(BTN_PASSWORD)).click();
+ }
+
+ @Test
+ public void testRemovePassword() {
+ openBrowser();
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).sendKeys("yyyyyyyyyy@mail.xx");
+ getDriver().findElement(By.xpath(BTN_PASSWORD)).click();
+
+ Assert.assertEquals(getDriver().findElement(GET_ERROR).getText(), "Неправильный логин или пароль");
+ }
+
+ @DataProvider(name = "randomEmail")
+ public Object[][] randomEmail() {
+ return new Object[][]{
+ {"rrrrrrrrrrrrrr@mail.yy"}, {"NNNNNNNNNN@mail.xx"}, {"22222222222@mail.xx"},
+ {"wmail@mail.xx"}, {"lllllllllly@mail.xx"}, {"wwww7777SSS@mail.xx"}
+ };
+ }
+
+ @Test(dataProvider = "randomEmail")
+ public void testRandomEmail(String name) {
+ openBrowser();
+ getDriver().findElement(By.xpath("//h2[@class='ant-typography h2_m Login__restore-text']")).click();
+
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).click();
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).sendKeys(name);
+
+ getDriver().findElement(By.xpath(BTN_PASSWORD)).click();
+
+ Assert.assertEquals(getDriver().findElement(GET_EMAIL).getText(), "Пользователь не найден, попробуйте снова");
+ }
+
+ @Test(dataProvider = "randomEmail")
+ public void testRandomRemoveEmail(String name) {
+ openBrowser();
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).sendKeys(name);
+ getDriver().findElement(By.xpath(BTN_PASSWORD)).click();
+
+ Assert.assertEquals(getDriver().findElement(GET_ERROR).getText(), "Неправильный логин или пароль");
+ }
+
+ @Test
+ public void testRega() {
+ openBrowser();
+ getDriver().findElement(By.xpath("//h2[@class='ant-typography h2_m Login__restore-text']")).click();
+
+ getDriver().findElement(By.xpath(INPUT_EMAIL)).sendKeys(EMAIL);
+ getDriver().findElement(By.xpath(BTN_PASSWORD)).click();
+
+ Assert.assertEquals(getDriver().findElement(GET_PASWORD).getText(), "Мы отправили по адресу f.ff.1980@list.ru ссылку для восстановления доступа");
+ }
+
+ @Test
+ public void testHrefPoliticUser() {
+ openBrowser();
+ getDriver().findElement(By.xpath("//a[@href='https://vr-arsoft.com/user-agreement-armobail/']")).click();
+
+ ArrayList newTab = new ArrayList<>(getDriver().getWindowHandles());
+ getDriver().switchTo().window(newTab.get(1));
+
+ Assert.assertEquals(getDriver().findElement(GET_POLITICA_USER).getText(), "Предмет пользовательского соглашения");
+ }
+
+ @Ignore
+ @Test
+ public void testCreateProgect() {
+ openBrowser();
+ login();
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorPrimary ']")).click();
+ getDriver().findElement(By.xpath("//input[@class='ant-input primaryInput not-entered']")).sendKeys("1Новый проект");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_city']")).sendKeys("Самара");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_country']")).sendKeys("РФ");
+ getDriver().findElement(By.xpath("//textarea[@id='CreateProjectForm_street']")).sendKeys("Победы");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_postalCode']")).sendKeys("444444");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_code']")).sendKeys("123");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_building']")).sendKeys("121");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_office']")).sendKeys("117");
+ getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_startDate']")).click();
+ getDriver().findElement(By.xpath("//a[@class='ant-picker-today-btn']")).click();
+
+ WebElement EndData = getDriver().findElement(By.xpath("//input[@id='CreateProjectForm_endDate']"));
+ EndData.sendKeys("26-05-2024");
+ EndData.sendKeys(Keys.ENTER);
+
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorPrimary ']")).click();
+ getDriver().findElement(By.xpath("//div[@class='ant-typography ant-typography-ellipsis ant-typography-single-line ant-typography-ellipsis-single-line p_r']")).click();
+ getDriver().findElement(By.xpath("//a[@style='color: inherit;'][contains(.,'Настройки')]")).click();
+
+ String newProgectName = getDriver().findElement(NEW_PROGECT_TEXT).getText();
+
+ Assert.assertEquals(newProgectName, "1Новый проект");
+
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorRed ']")).click();
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorPrimary '][contains(.,'Подтвердить')]")).click();
+ }
+
+ @Test
+ public void testHrefPolitic() {
+
+ openBrowser();
+
+ getDriver().findElement(By.xpath("//a[@href='https://vr-arsoft.com/personal-data-processing-policy/']")).click();
+
+ ArrayList newTab = new ArrayList<>(getDriver().getWindowHandles());
+ getDriver().switchTo().window(newTab.get(1));
+ String getErr = getDriver().findElement(GET_POLITICA).getText();
+
+ Assert.assertEquals(getErr, "Политика обработки персональных данных");
+ }
+
+ @Test
+ public void testHrefBot() {
+
+ openBrowser();
+ login();
+
+ getDriver().findElement(By.xpath("//a[@href='https://t.me/arsoft_support_bot']")).click();
+
+ ArrayList newTab = new ArrayList<>(getDriver().getWindowHandles());
+ getDriver().switchTo().window(newTab.get(1));
+ String getBot = getDriver().findElement(GET_BOT).getText();
+
+ Assert.assertEquals(getBot, "AR SOFT support");
+ }
+
+ @Ignore
+ @Test
+ public void testUserNab() {
+
+ openBrowser();
+ login();
+
+ getDriver().findElement(By.xpath("//a[@href='/users']")).click();
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorPrimary '] ")).click();
+ getDriver().findElement(By.xpath("//input[@id='InviteUserModal_email']")).sendKeys("yevgeniy.gor.91@mail.ru");
+
+ WebElement userRoles = getDriver().findElement(By.xpath("//input[@id='InviteUserModal_roles']"));
+ userRoles.click();
+ userRoles.sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ENTER);
+
+ WebElement createRole = getDriver().findElement(By.xpath("//input[@id='InviteUserModal_employmentId']"));
+ createRole.click();
+ createRole.sendKeys("Kir", Keys.ENTER);
+
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-primary primaryButton big colorPrimary ']")).click();
+
+ String getTextD = getDriver().findElement(By.xpath("//span[@class='anticon anticon-close-circle']")).getText();
+
+ Assert.assertEquals(getTextD, "Ошибка обращения к серверу");
+ }
+
+ @Ignore
+ @Test
+ public void testCreateUser() {
+
+ openBrowser();
+ login();
+
+ getDriver().findElement(By.xpath("//a[@href='/users']")).click();
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-default primaryButton big colorPrimary '] ")).click();
+ getDriver().findElement(By.xpath("//input[@id='InviteUserModal_email']")).sendKeys(EMAIL);
+
+ WebElement userRoles = getDriver().findElement(By.xpath("//input[@id='InviteUserModal_roles']"));
+ userRoles.click();
+ userRoles.sendKeys(Keys.ARROW_DOWN, Keys.ENTER);
+
+ getDriver().findElement(By.xpath("//button[@class='ant-btn ant-btn-primary primaryButton big colorPrimary ']")).click();
+
+ String getTextD = getDriver().findElement(By.xpath("//span[@class='anticon anticon-close-circle']")).getText();
+
+ Assert.assertEquals(getTextD, "Ошибка обращения к серверу");
+ }
+
+ @Test
+ public void testElementPeople() {
+ loginJenkins();
+ getDriver().findElement(By.xpath("//a[@href='/asynchPeople/']")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//div[@class='jenkins-app-bar__content']")).getText(), "People");
+ }
+
+ @Test
+ public void testElementWelcome() {
+ loginJenkins();
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("div h1")).getText(), "Welcome to Jenkins!");
+ }
+}
diff --git a/src/test/java/school/redrover/old/BmwTest.java b/src/test/java/school/redrover/old/BmwTest.java
new file mode 100644
index 0000000..7e0b79d
--- /dev/null
+++ b/src/test/java/school/redrover/old/BmwTest.java
@@ -0,0 +1,42 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import java.time.Duration;
+
+@Ignore
+public class BmwTest {
+ // Thread.sleep(2000) Добавлено для спецэффектов
+ @Test
+ public void testBmwSite() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().window().maximize();
+ driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(4));
+
+ driver.get("https://www.bmwmotorcycles.com/en/home.html");
+ Thread.sleep(2000);
+ driver.findElement(By.cssSelector(".svg-icon.svg-icon--search")).click();
+
+ WebElement searchField = driver.findElement(By.cssSelector("input[type='search']"));
+ Thread.sleep(2000);
+ searchField.sendKeys("CE 04");
+
+ WebElement searchButton = driver.findElement(By.cssSelector("button.search__go"));
+ Thread.sleep(2000);
+ searchButton.click();
+
+ WebElement link = driver.findElement(By.linkText("https://www.bmwmotorcycles.com/en/models/urban_mobility/ce04.html"));
+ Thread.sleep(2000);
+ link.click();
+
+ WebElement dataEquipmentLink = driver.findElement(By.linkText("Data & Equipment"));
+ Thread.sleep(2000);
+ dataEquipmentLink.click();
+
+// driver.quit();
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/ByteBustersGroupTest.java b/src/test/java/school/redrover/old/ByteBustersGroupTest.java
new file mode 100644
index 0000000..55fb7dc
--- /dev/null
+++ b/src/test/java/school/redrover/old/ByteBustersGroupTest.java
@@ -0,0 +1,345 @@
+package school.redrover.old;
+import org.openqa.selenium.*;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+
+@Ignore
+public class ByteBustersGroupTest extends BaseTest {
+
+ @Test
+ public void CoreTest() {
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(15));
+ getDriver().get("https://explorer.globe.engineer/");
+
+ WebElement textBox = wait.until(ExpectedConditions.elementToBeClickable(By.name("q")));
+
+ Assert.assertEquals(textBox.getAttribute("placeholder"), "I want to discover...");
+
+ String SearchWord = "IT";
+ textBox.sendKeys(SearchWord);
+ textBox.sendKeys(Keys.ENTER);
+
+ WebElement searchForElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//button[span[contains(text(), 'Search for:')]]")));
+ String testWord = searchForElement.getText();
+ Assert.assertEquals(testWord, SearchWord);
+ }
+
+ @Test
+ public void testSite() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ String title = getDriver().getTitle();
+ Assert.assertEquals("Swag Labs", title);
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ WebElement userName = getDriver().findElement(By.id("user-name"));
+ userName.sendKeys("visual_user");
+
+ WebElement passw = getDriver().findElement(By.id("password"));
+ passw.sendKeys("secret_sauce");
+
+ WebElement submitButton = getDriver().findElement(By.name("login-button"));
+ submitButton.click();
+
+ WebElement page = getDriver().findElement(By.className("title"));
+ String value = page.getText();
+
+ Assert.assertEquals("Products", value);
+ }
+
+ @Test
+ public void testLogin() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ WebElement login = getDriver().findElement(By.id("user-name"));
+ WebElement psw = getDriver().findElement(By.id("password"));
+ WebElement signInButton = getDriver().findElement(By.id("login-button"));
+
+ login.sendKeys("standard_user");
+ psw.sendKeys("secret_sauce");
+ signInButton.submit();
+
+ WebElement displayedPage = getDriver().findElement(By.className("title"));
+ String targetText = displayedPage.getText();
+ Assert.assertEquals(targetText, "Products");
+ }
+ @Test
+ public void wooordHunttest(){
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ getDriver().get("https://wooordhunt.ru/");
+
+ getDriver().findElement(By.id("hunted_word")).sendKeys("apple");
+ getDriver().findElement(By.id("hunted_word_submit")).click();
+
+ String value = getDriver().findElement(By.className("t_inline_en")).getText();
+
+ Assert.assertEquals("яблоко, яблоня, чепуха, лесть, яблочный", value);
+ }
+
+ @Test
+ public void testSearchOnFlashscore() {
+ getDriver().get("https://www.flashscore.ua/");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().findElement(By.id("search-window")).click();
+ getDriver().findElement(By.cssSelector("input")).sendKeys("aaaaaaaaa");
+
+ Assert.assertEquals(getDriver().findElement(By.className("searchResults__noResult"))
+ .getText(), "За Вашим запитом нічого не знайдено.");
+ }
+
+ @Test
+ public void testAddToCart() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(1000));
+
+ getDriver().findElement(By.name("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.name("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+ getDriver().findElement(By.id("add-to-cart-test.allthethings()-t-shirt-(red)")).click();
+ getDriver().findElement(By.className("shopping_cart_link")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.className("shopping_cart_badge")).getText(), "1");
+ Assert.assertEquals(getDriver().findElement(By.xpath("//a[@id='item_3_title_link']/div[@class = 'inventory_item_name']")).getText(), "Test.allTheThings() T-Shirt (Red)");
+ }
+
+ @Test
+ public void testRemoveFromCart() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(1000));
+
+ getDriver().findElement(By.name("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.name("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+ getDriver().findElement(By.id("add-to-cart-test.allthethings()-t-shirt-(red)")).click();
+ getDriver().findElement(By.id("remove-test.allthethings()-t-shirt-(red)")).click();
+ getDriver().findElement(By.className("shopping_cart_link")).click();
+
+ Assert.assertTrue(getDriver().findElements(By.className("shopping_cart_badge")).isEmpty());
+ Assert.assertTrue(getDriver().findElements(By.className("cart_item")).isEmpty());
+ }
+
+ @Test
+ public void googleTranslatorTest() {
+
+ getDriver().get("https://translate.google.com/#");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(2000));
+
+ WebElement textField = getDriver().findElement(By.className("er8xn"));
+ textField.sendKeys("Hello World");
+
+ WebElement translationFieldText = getDriver().findElement(By.
+ xpath("(//span[@class='ryNqvb'])[1]"));
+
+ Assert.assertEquals(translationFieldText.getText(), "Привет, мир");
+ }
+
+ @Test
+ public void xpathDinerTest() throws InterruptedException {
+
+ getDriver().get("https://topswagcode.com/xpath/");
+ getDriver().manage().window().maximize();
+
+ WebElement inputField = getDriver().findElement(By.
+ xpath("(//input[@placeholder='Type in a Xpath selector'])[1]"));
+ WebElement levelText = getDriver().findElement(By.xpath("//span[@class='level-text']"));
+
+ inputField.sendKeys("//plate ");
+ inputField.sendKeys(Keys.ENTER);
+
+ Thread.sleep(2000); //sorry, i can not use another variants - they do not work!
+
+ Assert.assertEquals(levelText.getText(), "Level 2 of 26");
+
+ }
+
+ @Test
+ public void testCounterStrike() {
+
+ WebDriver driver = getDriver();
+ driver.get("https://www.counter-strike.net/");
+
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(7));
+
+ WebElement buttonSelectLanguage = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".languageselector_InnerWrapper_A5ZD2 .languageselector_LanguageIcon_yTASe")));
+ buttonSelectLanguage.click();
+
+ WebElement selectEnglish= driver.findElement(By.className("languageselector_LanguageOption_Kd1K6"));
+ selectEnglish.click();
+
+ WebElement languageElement = driver.findElement(By.xpath("//div[@class='languageselector_InnerWrapper_A5ZD2']//span"));
+ String languageText = languageElement.getText();
+
+ Assert.assertEquals(languageText, "SELECT LANGUAGE");
+
+ }
+
+ @Test
+ public void testCheckITboxCart() throws InterruptedException {
+ int priceOfCurrentItem;
+ int currentValueOfCart = 0;
+ List actualValueOfCart = new ArrayList<>();
+ List expectedValueOfCart = new ArrayList<>();
+
+ getDriver().get("https://www.itbox.ua/");
+ getDriver().manage().window().maximize();
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().findElement(By.xpath("//div[@class='center-part']//input[@name='q']")).sendKeys("SSD Samsung");
+ getDriver().findElement(By.xpath("//div[@class='center-part']//button[@class='search-submit center']")).click();
+ currentValueOfCart += getItemPrice(1);
+
+ addItemToCart();
+ expectedValueOfCart.add(currentValueOfCart);
+ actualValueOfCart.add(getCartValue());
+
+ getDriver().navigate().back();
+ currentValueOfCart += getItemPrice(2);
+
+ addItemToCart();
+ expectedValueOfCart.add(currentValueOfCart);
+ actualValueOfCart.add(getCartValue());
+ Thread.sleep(200);
+
+ priceOfCurrentItem = Integer.parseInt(getDriver()
+ .findElement(By.xpath("//*[@class='stuff-price__row stuff-price__has-sale']//*[@class='stuff-price__digits scada']"))
+ .getText());
+
+ getDriver().findElement(By.xpath("(//button[@class='plusmin plusmin-plus '])[2]")).click();
+ Thread.sleep(500);
+
+ currentValueOfCart += priceOfCurrentItem;
+ expectedValueOfCart.add(currentValueOfCart);
+ actualValueOfCart.add(getCartValue());
+
+ getDriver().findElement(By.xpath("(//a[@class='cart-rm js-cart-rm'])[2]")).click();
+ getDriver().findElement(By.xpath("(//a[contains(@class, '_remove')])[2]")).click();
+ Thread.sleep(500);
+
+ currentValueOfCart -= priceOfCurrentItem * 2;
+ expectedValueOfCart.add(currentValueOfCart);
+ actualValueOfCart.add(getCartValue());
+
+ getDriver().findElement(By.xpath("//a[contains(@class, 'empty')]")).click();
+
+ for (int i = 0; i < expectedValueOfCart.size(); i++) {
+ Assert.assertEquals(actualValueOfCart.get(i), expectedValueOfCart.get(i));
+ }
+ Assert.assertTrue(getDriver()
+ .findElement(By.xpath("//div[@class='not-found__content']"))
+ .isDisplayed());
+ }
+
+ private void openCart(){
+ getDriver().findElement(By.xpath("//ul[contains(@class,'mobile')]//a[contains(@class,'cart')]")).click();
+ }
+ private int getCartValue(){
+ return Integer.parseInt(getDriver()
+ .findElement(By.xpath("//div[contains(@class, 'full')]//strong[contains(@class, 'price')]"))
+ .getText());
+ }
+
+ private void addItem(){
+ getDriver().findElement(By.xpath("(//a[@class='add add-cart'])[1]")).click();
+ }
+
+ private int getItemPrice(int itemNumber){
+ return Integer.parseInt(getDriver()
+ .findElement(By.xpath("(//*[@class='stuff-price__digits'])[" + itemNumber + "]"))
+ .getText());
+ }
+
+ private void pressTwiceEscape(){
+ getDriver().findElement(By.xpath("//body")).sendKeys(Keys.ESCAPE);
+ getDriver().findElement(By.xpath("//body")).sendKeys(Keys.ESCAPE);
+ }
+
+ private void addItemToCart() throws InterruptedException {
+ addItem();
+ pressTwiceEscape();
+ Thread.sleep(200);
+ openCart();
+ }
+
+ @Test
+ public void testSauceDemoPurchase() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.id("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+
+ getDriver().findElement(By.id("add-to-cart-sauce-labs-backpack")).click();
+ getDriver().findElement(By.id("shopping_cart_container")).click();
+ getDriver().findElement(By.id("checkout")).click();
+
+ getDriver().findElement(By.id("first-name")).sendKeys("First Name");
+ getDriver().findElement(By.id("last-name")).sendKeys("Last Name");
+ getDriver().findElement(By.id("postal-code")).sendKeys("123");
+ getDriver().findElement(By.id("continue")).click();
+ getDriver().findElement(By.name("finish")).click();
+ getDriver().findElement(By.name("back-to-products")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://www.saucedemo.com/inventory.html");
+ }
+ @Test
+ public void testCheckSortFantasyPlayersByPrice() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ getDriver().manage().window().maximize();
+
+ getDriver().get("https://fantasy.premierleague.com/");
+ if(getDriver().findElement(By.id("onetrust-policy-text")).isDisplayed()){
+ getDriver().findElement(By.id("onetrust-accept-btn-handler")).click();
+ }
+ getDriver().findElement(By.xpath("//*[text()='Statistics']")).click();
+ new Select(getDriver().findElement(By.id("sort"))).selectByVisibleText("Price");
+ List prices = getDriver().findElements(By.xpath("//tr[contains(@class, 'Row')]/td[3]"));
+
+ double currentValue = Double.parseDouble(prices.get(0).getText());
+ for (int i = 1; i < prices.size(); i++) {
+ double nextValue = Double.parseDouble(prices.get(i).getText());
+ Assert.assertTrue(nextValue <= currentValue, "Error of Sort!!");
+ currentValue = nextValue;
+ }
+ }
+ @Test
+ public void testEmailForm() {
+
+ getDriver().get("http://www.cmz.sumy.ua/");
+ WebElement button = getDriver().findElement(By.
+ xpath("(//a[@href='contact_ua.html'][contains(text(),'Контакти')])[1]"));
+
+ button.click();
+
+ WebElement textName = getDriver().findElement(By.cssSelector("input[name='T3']"));
+ textName.sendKeys("Name");
+ WebElement textTel = getDriver().findElement(By.cssSelector("input[name='T4']"));
+ textTel.sendKeys("911");
+ WebElement textEmail = getDriver().findElement(By.cssSelector("input[name='T5']"));
+ textEmail.sendKeys("test@.com");
+ WebElement textTopic = getDriver().findElement(By.cssSelector("input[name='T6']"));
+ textTopic.sendKeys("Test");
+ WebElement textComment = getDriver().findElement(By.cssSelector("textarea[name='T7']"));
+ textComment.sendKeys("It is negative test");
+
+ WebElement buttonSend = getDriver().findElement(By.xpath("(//input[@name='B1'])[1]"));
+ buttonSend.click();
+
+ WebElement buttonResult = getDriver().findElement(By.xpath("//li[contains(text(),'Обчисліть ще раз.')]"));
+
+ Assert.assertEquals(buttonResult.getText(), "Обчисліть ще раз.");
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/CalculatorPageTest.java b/src/test/java/school/redrover/old/CalculatorPageTest.java
new file mode 100644
index 0000000..f847650
--- /dev/null
+++ b/src/test/java/school/redrover/old/CalculatorPageTest.java
@@ -0,0 +1,37 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class CalculatorPageTest {
+
+ @Test
+ public void testPageCalculator(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://testpages.eviltester.com/styled/index.html");
+ WebElement link = driver.findElement(By.id("calculatetest"));
+ link.click();
+ WebElement textBox1 = driver.findElement(By.id("number1"));
+ textBox1.sendKeys("5");
+ WebElement textBox2 = driver.findElement(By.id("number2"));
+ textBox2.sendKeys("5");
+ WebElement button = driver.findElement(By.id("calculate"));
+ button.click();
+ WebElement result = driver.findElement(By.id("answer"));
+ Assert.assertEquals(result.getText(), "10");
+
+ driver.quit();
+
+ }
+
+}
+
+
diff --git a/src/test/java/school/redrover/old/CamelCaseGroupTest.java b/src/test/java/school/redrover/old/CamelCaseGroupTest.java
new file mode 100644
index 0000000..7f6db40
--- /dev/null
+++ b/src/test/java/school/redrover/old/CamelCaseGroupTest.java
@@ -0,0 +1,66 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class CamelCaseGroupTest extends BaseTest {
+ @Test
+ public void testCheckRedirectionProShop() {
+ getDriver().get("https://www.fairfaxicearena.com/");
+
+ WebElement proShopBtn = getDriver().findElement(By.xpath("//a[normalize-space()='Pro Shop']"));
+ proShopBtn.click();
+
+ String currentUrl = getDriver().getCurrentUrl();
+
+ WebElement appointmentRequestForm = getDriver().findElement(By.xpath("//span[contains(text(),'Pro Shop Appointment Request Form')]"));
+
+ Assert.assertEquals(currentUrl, "https://www.fairfaxicearena.com/pro-shop.html");
+ Assert.assertTrue(appointmentRequestForm.isDisplayed());
+ }
+
+ @Test
+ public void testTools() throws InterruptedException {
+
+ getDriver().get("https://www.saucedemo.com/");
+
+ WebElement text = getDriver().findElement(By.id("user-name"));
+ text.sendKeys("standard_user");
+
+ WebElement text1 = getDriver().findElement(By.id("password"));
+ text1.sendKeys("secret_sauce");
+
+ WebElement button = getDriver().findElement(By.id("login-button"));
+ button.click();
+
+ Thread.sleep(1000);
+
+ WebElement link = getDriver().findElement(By.className("app_logo"));
+ String resultText = link.getText();
+
+ Assert.assertEquals(resultText, "Swag Labs");
+ }
+
+ @Test
+ public void testWb() throws InterruptedException {
+
+ getDriver().get("https://www.wildberries.ru");
+
+ Thread.sleep(500);
+
+ WebElement searchInput = getDriver().findElement(By.id("searchInput"));
+ searchInput.sendKeys("177390212");
+
+ WebElement searchButton = getDriver().findElement(By.id("applySearchBtn"));
+ searchButton.click();
+
+ String currentURL = getDriver().getCurrentUrl();
+ Assert.assertEquals(currentURL, "https://www.wildberries.ru/catalog/0/search.aspx?search=177390212");
+ }
+}
diff --git a/src/test/java/school/redrover/old/CodeMagazineTasksAreaTest.java b/src/test/java/school/redrover/old/CodeMagazineTasksAreaTest.java
new file mode 100644
index 0000000..f5e6778
--- /dev/null
+++ b/src/test/java/school/redrover/old/CodeMagazineTasksAreaTest.java
@@ -0,0 +1,35 @@
+package school.redrover.old;
+
+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.interactions.Action;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class CodeMagazineTasksAreaTest {
+
+ @Test
+ public void testTasksArea() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://thecode.media/");
+
+ WebElement searchArea = driver.findElement(By.className("tab-questions"));
+
+ Action myAction = new Actions(driver).doubleClick(searchArea).build();
+ myAction.perform();
+
+ WebElement foundText = driver.findElement(By.xpath("(//h1[@class='search__title'])"));
+ String foundSearchTitle = foundText.getText();
+
+ Assert.assertEquals(foundSearchTitle, "Как решить");
+
+ driver.quit();
+
+ }
+
+}
diff --git a/src/test/java/school/redrover/old/CodeMagazineTest.java b/src/test/java/school/redrover/old/CodeMagazineTest.java
new file mode 100644
index 0000000..a3eb2ca
--- /dev/null
+++ b/src/test/java/school/redrover/old/CodeMagazineTest.java
@@ -0,0 +1,35 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class CodeMagazineTest {
+ @Test
+ public void testMCode() { // Home_Work 15
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://thecode.media/");
+
+ WebElement search_button = driver.findElement(By.className("heading-search__open"));
+ search_button.click();
+
+ WebElement search_text = driver.findElement(By.className("heading-search__input"));
+ search_text.sendKeys("Api");
+
+ search_button.click();
+
+ WebElement found_text = driver.findElement(By.className("search__title"));
+ String result_Search = found_text.getText();
+
+ Assert.assertEquals("api", result_Search);
+
+ driver.quit();
+
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/CodeQAGroupTest.java b/src/test/java/school/redrover/old/CodeQAGroupTest.java
new file mode 100644
index 0000000..c420eb8
--- /dev/null
+++ b/src/test/java/school/redrover/old/CodeQAGroupTest.java
@@ -0,0 +1,430 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+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 org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.awt.*;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+
+
+@Ignore
+public class CodeQAGroupTest extends BaseTest {
+
+ @Test
+ public void testSlider() {
+
+ getDriver().get("https://the-internet.herokuapp.com/horizontal_slider");
+
+ WebElement slider = getDriver().findElement(By.xpath("/html/body/div[2]/div/div/div/input"));
+ WebElement text = getDriver().findElement(By.xpath("//*[@id='range']"));
+
+ double expectedValue = 0;
+
+ Assert.assertEquals(Double.parseDouble(text.getText()), expectedValue);
+
+ final double step = 0.5;
+ for (int i = 0; i < 10; i++) {
+ slider.sendKeys(Keys.ARROW_RIGHT);
+ expectedValue += step;
+ Assert.assertEquals(Double.parseDouble(text.getText()), expectedValue);
+ }
+ for (int i = 0; i < 11; i++) {
+ Assert.assertEquals(Double.parseDouble(text.getText()), expectedValue);
+ slider.sendKeys(Keys.ARROW_LEFT);
+ expectedValue -= step;
+ }
+ }
+
+ public void preconditions() {
+ getDriver().get("http://localhost:8080/");
+
+ WebElement loginArea = getDriver().findElement(By.cssSelector("#j_username"));
+ loginArea.sendKeys("admin");
+
+ WebElement passwordArea = getDriver().findElement(By.cssSelector("#j_password"));
+ passwordArea.sendKeys("admin");
+
+ WebElement buttonSubmit = getDriver().findElement(By.name("Submit"));
+ buttonSubmit.click();
+
+ WebElement newItemButton = getDriver().findElement(By.linkText("New Item"));
+ newItemButton.click();
+ }
+
+ @Test
+ public void testFreestyleProject() {
+ preconditions();
+
+ WebElement itemNameField = getDriver().findElement(By.id("name"));
+ itemNameField.sendKeys("freestylePrTest39");
+
+ WebElement freestyleProjSelect = getDriver().findElement(By.className("hudson_model_FreeStyleProject"));
+ freestyleProjSelect.click();
+
+ WebElement buttonOK = getDriver().findElement(By.id("ok-button"));
+ buttonOK.click();
+ WebElement buttonSave = getDriver().findElement(By.name("Submit"));
+ buttonSave.click();
+
+ String actualRes = getDriver().findElement(By.tagName("h1")).getText();
+
+ Assert.assertEquals(actualRes, "Project freestylePrTest39");
+ }
+
+ @Test
+ public void testDropDownMenu() {
+ getDriver().get("https://the-internet.herokuapp.com");
+
+ WebElement dropDown = getDriver().findElement(By.linkText("Dropdown"));
+ dropDown.click();
+ WebElement dropDownMenu = getDriver().findElement(By.id("dropdown"));
+ dropDownMenu.click();
+ WebElement dropDownOption1 = getDriver().findElement(By.xpath("//*[@id='dropdown']/option[2]"));
+ dropDownOption1.click();
+
+ Assert.assertTrue(dropDownOption1.isDisplayed());
+ }
+
+ @Test
+ public void testCheckBox() {
+ getDriver().get("https://the-internet.herokuapp.com");
+
+ getDriver().findElement(By.linkText("Checkboxes")).click();
+ WebElement checkBox1 = getDriver().findElement(By.xpath("//*[@id='checkboxes']/input[1]"));
+ checkBox1.click();
+
+ Assert.assertTrue(checkBox1.isSelected());
+ }
+
+ @Test
+ public void testLinkToHorizontalSliderPage() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/horizontal_slider']")));
+
+ WebElement linkToHorizontalSliderPage = getDriver().findElement(
+ By.xpath("//a [@href='/horizontal_slider']"));
+ linkToHorizontalSliderPage.click();
+
+ String expectedResult = "Horizontal Slider";
+
+ String actualResult = getDriver().findElement(
+ By.xpath("//h3 [text() = 'Horizontal Slider']")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testHorizontalSliderMovedByMouse() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/horizontal_slider']")));
+
+ WebElement linkToHorizontalSliderPage = getDriver().findElement(
+ By.xpath("//a [@href='/horizontal_slider']"));
+ linkToHorizontalSliderPage.click();
+
+ String expectedResult = "1";
+
+ int x = getDriver().findElement(By.xpath("//input [@type='range']")).getLocation().getX() + 2;
+ int y = getDriver().findElement(By.xpath("//input [@type='range']")).getLocation().getY();
+ int width = getDriver().findElement(By.xpath("//input [@type='range']")).getSize().width;
+
+ double getStepValue = Double.parseDouble(getDriver().findElement(
+ By.xpath("//input [@type='range']")).getAttribute("step"));
+ double getMaxValue = Double.parseDouble(getDriver().findElement(
+ By.xpath("//input [@type='range']")).getAttribute("max"));
+ int getOffset = (int) (width / (getMaxValue / getStepValue));
+
+ int stepsQtt;
+
+ if (expectedResult.contains(".")) {
+ stepsQtt = (int) (Double.parseDouble(expectedResult) * 2);
+ } else {
+ stepsQtt = Integer.parseInt(expectedResult) * 2;
+ }
+
+ Actions mouse = new Actions(getDriver());
+
+ for (int i = 0; i < stepsQtt; i++) {
+ mouse.moveToLocation(x, y)
+ .clickAndHold()
+ .moveByOffset(getOffset, 0)
+ .release()
+ .perform();
+ x += getOffset;
+ }
+
+ String actualResult = getDriver().findElement(By.xpath("//span [@id='range']")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testDropdownList() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/dropdown']")));
+
+ WebElement linkToDropdownListPage = getDriver().findElement(
+ By.xpath("//a [@href='/dropdown']"));
+ linkToDropdownListPage.click();
+
+ String expectedResult = "Option 1, Option 2";
+
+ StringBuilder actualResult = new StringBuilder();
+
+ for (int i = 1; i <= 2; i++) {
+ WebElement DropdownOption = getDriver().findElement(
+ By.xpath("//select [@id = 'dropdown' ]/option [@value = '" + i + "']"));
+
+ if (i < 2) {
+ actualResult.append(DropdownOption.getText()).append(", ");
+ } else {
+ actualResult.append(DropdownOption.getText());
+ }
+ }
+
+ Assert.assertEquals(actualResult.toString(), expectedResult);
+ }
+
+ @Test
+ public void testDynamicallyLoadedPageElements() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ String expectedResult = "Hello World!";
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/dynamic_loading']")));
+
+ WebElement linkToDynamicallyLoadedPageElementsPage = getDriver().findElement(
+ By.xpath("//a [@href='/dynamic_loading']"));
+ linkToDynamicallyLoadedPageElementsPage.click();
+
+ WebElement linkToDynamicallyLoadedPageElementsPage1 = getDriver().findElement(
+ By.xpath("//a [@href='/dynamic_loading/1']"));
+ linkToDynamicallyLoadedPageElementsPage1.click();
+
+ WebElement startButton = getDriver().findElement(
+ By.xpath("//div [@id='start']/button"));
+ startButton.click();
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//div [@id='finish']")));
+
+ String actualResult = getDriver().findElement(
+ By.xpath("//div [@id='finish']")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testFloatingMenuPage() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/floating_menu']")));
+
+ WebElement linkToDynamicallyLoadedPageElementsPage = getDriver().findElement(
+ By.xpath("//a [@href='/floating_menu']"));
+ linkToDynamicallyLoadedPageElementsPage.click();
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//div [@id = 'menu']")));
+
+ Actions scrollDown = new Actions(getDriver());
+ scrollDown.scrollToElement(getDriver().findElement(
+ By.xpath("//a [@target='_blank']"))).build().perform();
+
+ boolean menuIsDisplayed = getDriver().findElement(
+ By.xpath("//div [@id = 'menu']")).isDisplayed();
+
+ Assert.assertTrue(menuIsDisplayed);
+ }
+
+ @Test
+ public void testFieldValidation() throws InterruptedException {
+
+ getDriver().get("http://allolosos.com.ua/ru/menu/pizza");
+
+ WebElement button = getDriver().findElement(By.xpath("//a[@href='/ru/director']"));
+ button.click();
+ Thread.sleep(1000);
+
+ WebElement textName = getDriver().findElement(By.id("feedbackdirector-name"));
+ textName.sendKeys("Miroslav");
+ String actualName = textName.getAttribute("value");
+ String expectedName = "Miroslav";
+
+ Assert.assertEquals(actualName, expectedName);
+
+ WebElement textPhone = getDriver().findElement(By.id("feedbackdirector-phone"));
+ textPhone.sendKeys("0502380088");
+ String actualPhone = textPhone.getAttribute("value");
+ String expectedPhone = "+38 (050) 238-00-88";
+
+ Assert.assertEquals(actualPhone, expectedPhone);
+
+ WebElement textMessage = getDriver().findElement(By.id("feedbackdirector-message"));
+ textMessage.sendKeys("Thank you very much");
+ String actualMessage = textMessage.getAttribute("value");
+ String expectedMessage = "Thank you very much";
+
+ Assert.assertEquals(actualMessage, expectedMessage);
+ }
+
+ @Test
+ public void testGoToAnotherPage() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+ getDriver().findElement(By.cssSelector("a[href='/abtest']")).click();
+ String actualResult = getDriver().findElement(By.cssSelector("h3")).getText();
+
+ Assert.assertEquals(actualResult, "A/B Test Control");
+ }
+
+ @Test
+ public void testForConflict() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/floating_menu']")));
+
+ WebElement linkToDynamicallyLoadedPageElementsPage = getDriver().findElement(
+ By.xpath("//a [@href='/exit_intent']"));
+ linkToDynamicallyLoadedPageElementsPage.click();
+
+ String expectedResult = "Exit Intent";
+
+ String actualResult = getDriver().findElement(
+ By.xpath("//h3")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testForConflict2() throws AWTException {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebDriverWait wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//a [@href='/exit_intent']")));
+
+ WebElement linkToExitIntentPage = getDriver().findElement(
+ By.xpath("//a [@href='/exit_intent']"));
+ linkToExitIntentPage.click();
+
+ Robot robot = new Robot();
+ robot.mouseMove(600, 0);
+
+ wait60.until(ExpectedConditions.visibilityOfElementLocated(
+ By.xpath("//div [@class='modal-title']/h3")));
+
+ String expectedResult = "This is a modal window";
+ expectedResult = expectedResult.toUpperCase();
+
+ String actualResult = getDriver().findElement(
+ By.xpath("//div [@class='modal-title']/h3")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testLoginFormWithEmptyFields() {
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ getDriver().findElement(By.cssSelector("a[href='/login']")).click();
+ getDriver().findElement(By.xpath("//*[@class='radius']")).click();
+ String actualResult = getDriver().findElement(By.id("flash")).getText();
+
+ Assert.assertTrue(actualResult.contains("Your username is invalid!"));
+ }
+
+ @Test
+ public void testDropDown() {
+
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebElement atrValue = getDriver().findElement(By.xpath("//a[@href='/dropdown']"));
+ atrValue.click();
+ WebElement dropdown = getDriver().findElement(By.xpath("//*[@id='dropdown']"));
+ dropdown.click();
+ List exResult = new ArrayList<>();
+ exResult.add("Option 1");
+ exResult.add("Option 2");
+ List acResult = new ArrayList<>();
+ acResult.add(getDriver().findElement(By.cssSelector("#dropdown > option:nth-child(2)")).getText());
+ acResult.add(getDriver().findElement(By.cssSelector("#dropdown > option:nth-child(3)")).getText());
+
+ Assert.assertEquals(acResult, exResult);
+ }
+ @Test
+ public void testAddElement() {
+ getDriver().get("https://the-internet.herokuapp.com/");
+ WebElement atrValue = getDriver().findElement(By.cssSelector("#content > ul > li:nth-child(2) > a"));
+ atrValue.click();
+ WebElement header3 = getDriver().findElement(By.xpath("/html/body/div[2]/div/div/button"));
+ Assert.assertEquals(header3.getText(), "Add Element");
+ }
+ @Test
+ public void testDeleteBtn() {
+
+ getDriver().get("https://the-internet.herokuapp.com/add_remove_elements/");
+
+ WebElement addButton = getDriver().findElement(By.xpath("/html/body/div[2]/div/div/button"));
+ addButton.click();
+
+ boolean deleteButtonVisible = getDriver().findElement(By.xpath("/html/body/div[2]/div/div/div/button")).isDisplayed();
+
+ Assert.assertTrue(deleteButtonVisible);
+ }
+ @Test
+ public void testCheckboxDynamicControls() throws InterruptedException {
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ WebElement dynamicControls = getDriver().findElement(By.xpath("//a[@href=\'/dynamic_controls\']"));
+ dynamicControls.click();
+ WebElement checkbox = getDriver().findElement(By.xpath("//input[@type='checkbox']"));
+ checkbox.click();
+ Thread.sleep(3000);
+ WebElement buttonRemove = getDriver().findElement(By.xpath("//form[@id='checkbox-example']/button"));
+ buttonRemove.click();
+ Thread.sleep(5000);
+ String actualResult = getDriver().findElement(By.xpath("//p[@id='message']")).getText();
+
+ Assert.assertEquals(actualResult, "It's gone!");
+ }
+}
diff --git a/src/test/java/school/redrover/old/CopyCatTest.java b/src/test/java/school/redrover/old/CopyCatTest.java
new file mode 100644
index 0000000..1e3cc0c
--- /dev/null
+++ b/src/test/java/school/redrover/old/CopyCatTest.java
@@ -0,0 +1,33 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class CopyCatTest {
+ @Test
+ public void testGoogle() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://google.com");
+
+ WebElement text = driver.findElement(By.id("APjFqb"));
+ text.sendKeys("Selenium");
+
+ Thread.sleep(1100);
+
+ WebElement button = driver.findElement(By.className("gNO89b"));
+ button.click();
+
+ WebElement link = driver.findElement(By.xpath("//a[@href = 'https://www.selenium.dev/']/h3"));
+ String resultText = link.getText();
+
+ Assert.assertEquals(resultText, "Selenium");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/CountSymbolsTest.java b/src/test/java/school/redrover/old/CountSymbolsTest.java
new file mode 100644
index 0000000..05a30d8
--- /dev/null
+++ b/src/test/java/school/redrover/old/CountSymbolsTest.java
@@ -0,0 +1,35 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class CountSymbolsTest {
+
+ private final String URL = "https://involta.ru/tools/length-chars/";
+ private final String TEST_TEXT = "Это мой Текст из русских слов, слова dot и 1 цифры.";
+
+ @Test
+ public void testCountSymbols() {
+
+ int expectedResult = 2;
+
+ WebDriver driver = new ChromeDriver();
+ driver.get(URL);
+
+ driver.findElement(By.id("input")).sendKeys(TEST_TEXT);
+ driver.findElement(By.xpath("//button[@type='submit']")).click();
+ String text =
+ driver.findElement(By.xpath("//div/span[text()='Остальных символов']/following-sibling::span")).getText();
+
+ int actualResult = Integer.parseInt(text.trim());
+
+ Assert.assertEquals(actualResult, expectedResult);
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/CountTotalNumber.java b/src/test/java/school/redrover/old/CountTotalNumber.java
new file mode 100644
index 0000000..43b7cdd
--- /dev/null
+++ b/src/test/java/school/redrover/old/CountTotalNumber.java
@@ -0,0 +1,31 @@
+package school.redrover.old;
+
+import org.testng.annotations.Ignore;
+
+@Ignore
+public class CountTotalNumber {
+ public static void main (String[] args) {
+ String str = "I enjoy coding and java is everything"; //7 words
+
+ //convert string to String arra using split method and pass (space) as parameter
+ String[] strArray = str.split(" ");
+
+ //the length of the string array will be the total word COUNT
+ System.out.println("Word Count: " + strArray.length);
+
+ System.out.println("*******************");
+ //incasw if we need to print each word then we have to loop through the strArray
+ for ( int i = 0; i < strArray.length; i++){
+ System.out.println(strArray[i]);
+ }
+ System.out.println("*******************");
+ }
+ public int getCountTotal (String str){
+ int result = 0;
+ // convert strung to String arr using split method & pass as parametr
+ String[] strArray = str.split(" ");
+ result = strArray.length;
+ return result;
+ }
+ }
+
diff --git a/src/test/java/school/redrover/old/CrazyTestersTest.java b/src/test/java/school/redrover/old/CrazyTestersTest.java
new file mode 100644
index 0000000..e08e5e9
--- /dev/null
+++ b/src/test/java/school/redrover/old/CrazyTestersTest.java
@@ -0,0 +1,175 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+@Ignore
+public class CrazyTestersTest extends BaseTest {
+
+ @Test
+ public void testDragAndDrop() {
+ getDriver().get("https://the-internet.herokuapp.com/drag_and_drop");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
+
+ WebElement columnA = getDriver().findElement(By.id("column-a"));
+ WebElement columnB = getDriver().findElement(By.id("column-b"));
+ new Actions(getDriver())
+ .dragAndDrop(columnA, columnB)
+ .perform();
+
+ Assert.assertEquals(columnB.getText(), "A");
+ }
+
+ @Test
+ public void testSubmitForm() {
+ WebDriver driver = getDriver();
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ driver.get("https://demoqa.com/automation-practice-form");
+
+ WebElement textName = driver.findElement(By.id("firstName"));
+ textName.sendKeys("Anastasia");
+
+ WebElement textLastName = driver.findElement(By.id("lastName"));
+ textLastName.sendKeys("Belugina");
+
+ WebElement radioButton = driver.findElement(By.xpath("//label[text()='Female']"));
+ radioButton.click();
+
+ WebElement textMobile = driver.findElement(By.id("userNumber"));
+ textMobile.sendKeys("1234567890");
+
+ WebElement submitButton = driver.findElement(By.id("submit"));
+ js.executeScript("arguments[0].scrollIntoView();", submitButton);
+ submitButton.click();
+
+ WebElement result = driver.findElement(By.id("example-modal-sizes-title-lg"));
+ String resultText = result.getText();
+
+ Assert.assertEquals("Thanks for submitting the form", resultText);
+ }
+
+ @Test
+
+ public void testDemoQaElementsRadioButtonYes() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/");
+
+ Thread.sleep(1000);
+
+ WebElement buttonBookStoreApplication = driver.findElement(
+ By.xpath("//h5[text()='Book Store Application']"));
+ new Actions(driver).scrollToElement(buttonBookStoreApplication).perform();
+
+ WebElement buttonElements = driver.findElement(
+ By.xpath("//h5[text()='Elements']"));
+ buttonElements.click();
+
+ WebElement buttonRadioButton = driver.findElement(
+ By.xpath("//span[text()='Radio Button']"));
+ buttonRadioButton.click();
+
+ WebElement buttonYesRadio = driver.findElement(
+ By.xpath("//label[@class='custom-control-label'][1]"));
+ buttonYesRadio.click();
+
+ WebElement text = driver.findElement(
+ By.xpath("//span[@class='text-success']"));
+ String resultText = text.getText();
+
+ Assert.assertEquals(resultText, "Yes");
+
+ driver.quit();
+
+ }
+
+ @Test
+ public void placeholderFillTest(){
+ WebDriver driver = getDriver();
+ // driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement textBoxUser = driver.findElement(By.name("user-name"));
+ textBoxUser.sendKeys("standard_user");
+ WebElement textBoxPass = driver.findElement(By.id("password"));
+ textBoxPass.sendKeys("secret_sauce");
+ WebElement submitButton = driver.findElement(By.id("login-button"));
+
+ submitButton.click();
+
+ String currentUrl = driver.getCurrentUrl();
+ Assert.assertEquals(currentUrl, "https://www.saucedemo.com/inventory.html");
+
+ }
+ @Test
+ public void testW3schools() {
+
+ WebDriver driver = getDriver();
+ driver.get("https://www.w3schools.com/");
+
+ WebElement link = driver.findElement(By.linkText("Java Tutorial"));
+ link.click();
+
+ WebElement menu = driver.findElement(By.cssSelector("#menubtn_container > span > a"));
+ menu.click();
+
+ WebElement link2 = driver.findElement(By.linkText("Java Variables"));
+ link2.click();
+
+ WebElement text1 = driver.findElement(By.name("ex1"));
+ text1.sendKeys("String");
+
+ WebElement text2 = driver.findElement(By.name("ex2"));
+ text2.sendKeys("carName");
+
+ WebElement text3 = driver.findElement(By.name("ex3"));
+ text3.sendKeys("\"Volvo\"");
+
+ WebElement button = driver.findElement(By.cssSelector("#w3-exerciseform > div > button"));
+ String resultText = button.getText();
+ Assert.assertEquals(resultText, "Submit Answer »");
+ button.click();
+ }
+
+ @Test
+ public void testTest3() {
+ WebDriver driver = getDriver();
+ driver.get("https://www.nike.com/es/");
+
+ WebElement username = driver.findElement(By.id("VisualSearchInput"));
+ username.sendKeys("Jordan");
+
+ WebElement submitButton2 = driver.findElement(By.xpath("//button[@*='Buscar']"));
+ submitButton2.click();
+
+ String pageUrl = driver.getCurrentUrl();
+ Assert.assertEquals(pageUrl, "https://www.nike.com/es/w?q=Jordan&vst=Jordan");
+ }
+
+ @Test
+ public void testTest2() {
+ WebDriver driver = getDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement username = driver.findElement(By.id("user-name"));
+ username.sendKeys("standard_user");
+
+ WebElement password = driver.findElement(By.id("password"));
+ password.sendKeys("secret_sauce");
+
+ WebElement submitButton = driver.findElement(By.id("login-button"));
+ submitButton.click();
+
+ String pageTitle = driver.getTitle();
+ Assert.assertEquals(pageTitle, "Swag Labs");
+ }
+}
diff --git a/src/test/java/school/redrover/old/DMVTest.java b/src/test/java/school/redrover/old/DMVTest.java
new file mode 100644
index 0000000..7fbaabc
--- /dev/null
+++ b/src/test/java/school/redrover/old/DMVTest.java
@@ -0,0 +1,44 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import java.util.ArrayList;
+
+
+@Ignore
+public class DMVTest {
+
+ @Test
+ public void testSearch() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.dmv.ca.gov/portal/");
+
+ WebElement textBox = driver.findElement(By.id("site-header-search-input"));
+ textBox.sendKeys("SPECIAL INTEREST AND PERSONALIZED LICENSE PLATES ORDERS");
+
+ WebElement submitButton = driver.findElement(By.className("site-header__search-submit"));
+ submitButton.click();
+ Thread.sleep(3000);
+
+ WebElement orderButton = driver.findElement(By.xpath("//a[contains(text(),'Order personalized plates')]"));
+ orderButton.click();
+
+ ArrayList tabs = new ArrayList<>(driver.getWindowHandles());
+ driver.switchTo().window(tabs.get(tabs.size() - 1));
+
+ WebElement orderButton2 = driver.findElement(By.xpath("//a[contains(text(),'Order personalized plates')]"));
+ orderButton2.click();
+
+ WebElement name = driver.findElement(By.xpath("//h2[@class=\"text--h3 mb-24\"]"));
+ String value = name.getText();
+ Thread.sleep(2000);
+ Assert.assertEquals(value, "Terms & Acknowledgement");
+
+ driver.quit();
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/DemowebshopTest.java b/src/test/java/school/redrover/old/DemowebshopTest.java
new file mode 100644
index 0000000..0d11036
--- /dev/null
+++ b/src/test/java/school/redrover/old/DemowebshopTest.java
@@ -0,0 +1,74 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class DemowebshopTest {
+ @Test
+ public void testDemowebshop() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demowebshop.tricentis.com/");
+
+ WebElement text = driver.findElement(By.id("small-searchterms"));
+ text.sendKeys("computer");
+
+ Thread.sleep(1000); //ждет секунду
+
+ WebElement button = driver.findElement(By.xpath("//input[@class='button-1 search-box-button']"));
+ button.click();
+ Thread.sleep(2000);
+
+ WebElement SearchKeyword = driver.findElement(By.cssSelector(".page-title"));
+ String resultText = SearchKeyword.getText();
+
+
+
+ Assert.assertEquals(resultText, "Search");
+
+ driver.quit();
+ }
+
+ @Test
+ public void testDemowebshop1() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demowebshop.tricentis.com/");
+
+ WebElement button = driver.findElement(By.xpath("//a[@href = '/computers']"));
+ button.click();
+ Thread.sleep(2000);
+
+ WebElement SearchKeyword = driver.findElement(By.cssSelector(".page-title"));
+ String resultText = SearchKeyword.getText();
+
+ Assert.assertEquals(resultText, "Computers");
+
+ driver.quit();
+ }
+
+ @Test
+ public void testDemowebshop2() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demowebshop.tricentis.com/");
+
+ WebElement button = driver.findElement(By.xpath("//ul[@class='list' ]//li[@class='inactive']//a[@href='/computers']"));
+ button.click();
+ Thread.sleep(2000);
+
+ WebElement button1 = driver.findElement(By.xpath("//ul[@class='sublist' ]//li[@class='inactive']//a[@href = '/desktops']"));
+ button1.click();
+ Thread.sleep(2000);
+
+ WebElement SearchKeyword = driver.findElement(By.cssSelector(".page-title"));
+ String resultText = SearchKeyword.getText();
+
+ Assert.assertEquals(resultText, "Desktops");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/DoradoMainHw15Test.java b/src/test/java/school/redrover/old/DoradoMainHw15Test.java
new file mode 100644
index 0000000..48a3e6b
--- /dev/null
+++ b/src/test/java/school/redrover/old/DoradoMainHw15Test.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class DoradoMainHw15Test {
+
+ @Test
+ public void testAskomdch() {
+
+ WebDriver driver = new ChromeDriver();
+
+ driver.get("https://askomdch.com/");
+ driver.findElement(By.id("menu-item-1229")).click();
+
+ WebElement search = driver.findElement(By.id("woocommerce-product-search-field-0"));
+ search.sendKeys("jeans");
+
+ search.sendKeys(Keys.RETURN);
+
+ WebElement SearchResults = driver.findElement(By.className("woocommerce-products-header"));
+ String value = SearchResults.getText();
+ Assert.assertEquals(value, "Search results: “jeans”");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/DromTest.java b/src/test/java/school/redrover/old/DromTest.java
new file mode 100644
index 0000000..2e63d73
--- /dev/null
+++ b/src/test/java/school/redrover/old/DromTest.java
@@ -0,0 +1,38 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class DromTest {
+ @Test
+ public void testDrom() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().window().maximize();
+ driver.get("https://auto.drom.ru/");
+
+ WebElement carBrand = driver.findElement(By.xpath("//input[@placeholder='Марка']"));
+ carBrand.click();
+
+ WebElement selectBrand = driver.findElement(By.xpath("//div[@class='css-1r0zrug e1uu17r80']//div[@role='option']"));
+ selectBrand.click();
+
+ WebElement notSell = driver.findElement(By.xpath("//label[@for='sales__filter_unsold']"));
+ notSell.click();
+
+ WebElement buttonSubmit = driver.findElement(By.xpath("//div[text()='Показать']"));
+ buttonSubmit.click();
+
+ WebElement result = driver.findElement(By.cssSelector(".css-qg9fv5.e75dypj1"));
+ String resultValue = result.getText();
+ Assert.assertEquals("Сначала новые объявления", resultValue);
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/FacebookTest.java b/src/test/java/school/redrover/old/FacebookTest.java
new file mode 100644
index 0000000..61a52f9
--- /dev/null
+++ b/src/test/java/school/redrover/old/FacebookTest.java
@@ -0,0 +1,30 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class FacebookTest extends BaseTest {
+ @Test
+ public void autorizeInFacebook() {
+ getDriver().get("https://www.facebook.com/?locale=ru_RU");
+
+ WebElement userlogin = getDriver().findElement(By.id("email"));
+ userlogin.sendKeys("test");
+
+ WebElement userpassword = getDriver().findElement(By.id("pass"));
+ userpassword.sendKeys("pass");
+
+ WebElement sumbitButton = getDriver().findElement(By.name("login"));
+ sumbitButton.click();
+
+ WebElement modalWindow = getDriver().findElement(By.xpath(".//div[text()='Это ваш аккаунт?']"));
+ String checkModalWindowName = modalWindow.getText();
+ Assert.assertEquals(checkModalWindowName, "Это ваш аккаунт?");
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/FarfetchTest.java b/src/test/java/school/redrover/old/FarfetchTest.java
new file mode 100644
index 0000000..da8c172
--- /dev/null
+++ b/src/test/java/school/redrover/old/FarfetchTest.java
@@ -0,0 +1,33 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class FarfetchTest {
+
+ @Test
+ public void FarfetchTest () {
+
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.farfetch.com/designers/women");
+
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).sendKeys("Valentino");
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).click();
+
+
+
+ driver.get("https://www.farfetch.com/shopping/women/items.aspx");
+
+ driver.findElement(By.xpath("//input[@data-component='SearchInputControlled']")).sendKeys("YSL Heels");
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).click();
+
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/FirstAddTest.java b/src/test/java/school/redrover/old/FirstAddTest.java
new file mode 100644
index 0000000..0e9e099
--- /dev/null
+++ b/src/test/java/school/redrover/old/FirstAddTest.java
@@ -0,0 +1,40 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class FirstAddTest extends BaseTest {
+
+ @Test
+
+ public void testComputers (){
+ WebDriver driver =getDriver();
+ driver.get("https://computer-database.gatling.io/computers");
+
+ WebElement addButton = driver.findElement(By.id("add"));
+ addButton.click();
+ WebElement computerName = driver.findElement(By.id("name"));
+ computerName.sendKeys("macbook");
+ WebElement Introduced = driver.findElement(By.id("introduced"));
+ Introduced.sendKeys("2022-01-23");
+ WebElement companyName = driver.findElement(By.id("company"));
+ companyName.click();
+ WebElement choice = driver.findElement(By.className("blank"));
+ choice.isSelected();
+ WebElement submitButton = driver.findElement(By.cssSelector("#main > form > div > input"));
+ submitButton.click();
+
+ WebElement alert = driver.findElement(By.xpath("//*[@id=\"main\"]/div[1]"));
+ alert.isDisplayed();
+ String message = alert.getText();
+ Assert.assertEquals(message,"Done ! Computer macbook has been created");
+
+ }
+
+}
diff --git a/src/test/java/school/redrover/old/GoogleTest.java b/src/test/java/school/redrover/old/GoogleTest.java
new file mode 100644
index 0000000..22282da
--- /dev/null
+++ b/src/test/java/school/redrover/old/GoogleTest.java
@@ -0,0 +1,31 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class GoogleTest extends BaseTest {
+
+ @Test
+ public void testGoogle() throws InterruptedException {
+ getDriver().get("https://www.google.com");
+
+ WebElement text = getDriver().findElement(By.id("APjFqb"));
+ text.sendKeys("Selenium");
+
+ Thread.sleep(1000); // make it 500
+
+ WebElement button = getDriver().findElement(By.className("gNO89b"));
+ button.click();
+
+ WebElement link = getDriver().findElement(By.xpath("//a[@href = 'https://www.selenium.dev/']/h3"));
+ String resultText = link.getText();
+
+ Assert.assertEquals(resultText, "Selenium");
+ }
+}
diff --git a/src/test/java/school/redrover/old/GoogleTestAP.java b/src/test/java/school/redrover/old/GoogleTestAP.java
new file mode 100644
index 0000000..3cc4eb5
--- /dev/null
+++ b/src/test/java/school/redrover/old/GoogleTestAP.java
@@ -0,0 +1,33 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class GoogleTestAP {
+ @Test
+ public void GoogleTestAP() {
+ String expectedResult = "https://www.saucedemo.com/inventory.html";
+
+ WebDriver driver = new FirefoxDriver();
+
+ driver.get("https://www.saucedemo.com/");
+ WebElement name = driver.findElement(By.xpath("//input[@id='user-name']"));
+ name.sendKeys("not_standard_user");
+ WebElement passcode = driver.findElement(By.xpath("//input[@id='password']"));
+ passcode.sendKeys("secret_sauce");
+ driver.findElement(By.id("login-button")).click();
+
+ String actualResult = driver.getCurrentUrl();
+
+ Assert.assertEquals(actualResult, expectedResult);
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupAqaQuaQuaTest.java b/src/test/java/school/redrover/old/GroupAqaQuaQuaTest.java
new file mode 100644
index 0000000..739257d
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupAqaQuaQuaTest.java
@@ -0,0 +1,313 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.util.List;
+
+@Ignore
+public class GroupAqaQuaQuaTest extends BaseTest {
+
+ @Test
+ public void testyAddingBookToCart() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+
+ WebElement books = getDriver().findElement(By.xpath("//ul[@class='top-menu']//a[@href='/books']"));
+ books.click();
+
+ WebElement myBook = getDriver().findElement(By.xpath("//div[@class = 'details']//a[@href= '/computing-and-internet']"));
+ myBook.click();
+
+ WebElement addMyBook = getDriver().findElement(By.id("add-to-cart-button-13"));
+ addMyBook.click();
+
+ WebElement shoppingCart = getDriver().findElement(By.className("cart-label"));
+ shoppingCart.click();
+
+
+ Assert.assertEquals(getDriver().findElement(By.className("product-name")).getText(), "Computing and Internet");
+
+ }
+ @Test
+ public void testDropDownMenuGiftCards() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ WebElement elementDropDownMenu = getDriver().findElement(
+ By.xpath("//a[@href='/gift-cards']"));
+ elementDropDownMenu.click();
+
+ Assert.assertEquals(getDriver().getTitle(), "Demo Web Shop. Gift Cards");
+
+ WebElement menuOnPageGiftCards = getDriver().findElement((
+ By.cssSelector("div.page.category-page>div.page-title>h1")
+ ));
+ Assert.assertEquals(menuOnPageGiftCards.getText(), "Gift Cards");
+ }
+ @Test
+ public void testLoginTheInternet() {
+ getDriver().get("https://the-internet.herokuapp.com/");
+
+ Assert.assertEquals(getDriver().getTitle(), "The Internet");
+
+ getDriver().findElement(By.linkText("Form Authentication")).click();
+
+ getDriver().findElement(By.id("username")).sendKeys("tomsmith");
+ getDriver().findElement(By.id("password")).sendKeys("SuperSecretPassword!");
+ getDriver().findElement(By.cssSelector("button")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.tagName("h2")).getText(), "Secure Area");
+ }
+ @Test
+ public void testRegistration() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ Assert.assertEquals(getDriver().getTitle(), "Demo Web Shop");
+
+ getDriver().findElement(By.className("ico-register")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.tagName("h1")).getText(), "Register");
+
+ getDriver().findElement(By.id("gender-male")).click();
+ getDriver().findElement(By.id("FirstName")).sendKeys("Topper");
+ getDriver().findElement(By.id("LastName")).sendKeys("Harley");
+ getDriver().findElement(By.id("Email")).sendKeys("topperharley@hotmail.com");
+ getDriver().findElement(By.id("Password")).sendKeys("HotShots");
+ getDriver().findElement(By.id("ConfirmPassword")).sendKeys("HotShots");
+ getDriver().findElement(By.id("register-button")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.className("validation-summary-errors")).getText(),
+ "The specified email already exists");
+ }
+ @Test
+ public void testLoginPositive() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ Assert.assertEquals(getDriver().getTitle(), "Demo Web Shop");
+
+ getDriver().findElement(By.className("ico-login")).click();
+ getDriver().findElement(By.id("Email")).sendKeys("topperharley@hotmail.com");
+ getDriver().findElement(By.id("Password")).sendKeys("HotShots");
+ getDriver().findElement(By.id("RememberMe")).click();
+ getDriver().findElement(By.className("login-button")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.className("account")).getText(),
+ "topperharley@hotmail.com");
+ }
+ @Test
+ public void testCameraSortByLowPrise() {
+ getDriver().get("https://demowebshop.tricentis.com/camera-photo");
+
+ getDriver().findElement(By.name("products-orderby")).click();
+ Select sortBy = new Select(getDriver().findElement(By.name("products-orderby")));
+ sortBy.selectByVisibleText("Price: Low to High");
+
+ getDriver().findElement(By.id("products-viewmode")).click();
+ Select viewAs = new Select(getDriver().findElement(By.id("products-viewmode")));
+ viewAs.selectByVisibleText("List");
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("span.actual-price")).getText(), "349.00");
+ }
+
+ @Test
+ public void testAddGiftCardToCart() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ WebElement selectSortBy = getDriver().findElement(
+ By.cssSelector("div.header-menu>ul.top-menu>li>a[href='/gift-cards']"));
+ selectSortBy.click();
+
+ getDriver().findElement(
+ By.cssSelector("div.product-grid>div.item-box>div.product-item[data-productid='1']>div.picture"))
+ .click();
+ getDriver().findElement(
+ By.cssSelector("div.breadcrumb>ul>li>strong.current-item"));
+
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div.breadcrumb>ul>li>strong.current-item")).getText(), "$5 VIRTUAL GIFT CARD");
+
+ getDriver().findElement(
+ By.cssSelector("input#giftcard_1_RecipientName")).sendKeys("Ippolit");
+ getDriver().findElement(
+ By.cssSelector("input#giftcard_1_RecipientEmail")).sendKeys("ippolit@mail.ru");
+ getDriver().findElement(
+ By.cssSelector("input#giftcard_1_SenderName")).sendKeys("Barbara");
+ getDriver().findElement(
+ By.cssSelector("input#giftcard_1_SenderEmail")).sendKeys("barbara@mail.com");
+ getDriver().findElement(
+ By.cssSelector("textarea#giftcard_1_Message")).sendKeys("Тебе от меня! :)");
+ getDriver().findElement(
+ By.cssSelector("input[type='button']#add-to-cart-button-1")).click();
+ getDriver().findElement(
+ By.cssSelector("div.header-links>ul>li#topcartlink")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://demowebshop.tricentis.com/cart");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div.page-title>h1")).getText(), "Shopping cart");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.product>a.product-name")).getText(), "$5 Virtual Gift Card");
+ // как подцепить эл.адреса?
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.unit-price.nobr>span.product-unit-price")).getText(), "5.00");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.qty.nobr>input.qty-input")).getAttribute("value"), "1");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.subtotal.nobr.end>span.product-subtotal")).getText(), "5.00");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.cart-total-right>span.nobr>span.product-price")).getText(), "5.00");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("td.cart-total-right>span.nobr>span.product-price.order-total>strong"))
+ .getText(), "5.00");
+
+ getDriver().findElement(By.id("termsofservice")).click();
+ getDriver().findElement(By.id("checkout")).click();
+
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div.page-title>h1")).getText(), "Welcome, Please Sign In!");
+ }
+ @Test
+ public void testSearch() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ getDriver().findElement(By.linkText("Search")).click();
+
+ getDriver().findElement(By.cssSelector("[id= 'Q']")).sendKeys("corel");
+
+ getDriver().findElement(By.id("As")).click();
+ new Select(getDriver().findElement(By.id("Cid"))).selectByVisibleText("All");
+ getDriver().findElement(By.id("Isc")).click();
+ new Select(getDriver().findElement(By.id("Mid"))).selectByVisibleText("All");
+
+ getDriver().findElement(By.className("price-from")).sendKeys("0");
+ getDriver().findElement(By.className("price-to")).sendKeys("1000000");
+ getDriver().findElement(By.id("Sid")).click();
+ getDriver().findElement(By.cssSelector("[class^='search-i'] [type= 'submit']")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("h2 a[href^= '/corel']")).getText(),
+ "Corel Paint Shop Pro Photo X2");
+ }
+ @Test
+ public void testNewsletterPositive() throws InterruptedException {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ getDriver().findElement(By.cssSelector("[name^='News']")).sendKeys("topperharley@hotmail.com");
+ getDriver().findElement(By.cssSelector("[value^='Sub']")).click();
+ Thread.sleep(500);
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("[class$='result-block']")).getText().substring(0,5),
+ "Thank");
+ }
+ @Test
+ public void testNewsletterNegative() throws InterruptedException {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ getDriver().findElement(By.cssSelector("[name^='News']")).sendKeys("hotmail.com");
+ getDriver().findElement(By.cssSelector("[value^='Sub']")).click();
+ Thread.sleep(500);
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("[id$='result-block']")).getText(), "Enter valid email");
+ }
+ @Test
+ public void testLoginNegativePass() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ getDriver().findElement(By.className("ico-login")).click();
+ getDriver().findElement(By.id("Email")).sendKeys("topperharley@hotmail.com");
+ getDriver().findElement(By.id("Password")).sendKeys("Hot");
+ getDriver().findElement(By.id("RememberMe")).click();
+ getDriver().findElement(By.className("login-button")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//form/div[1]/div/ul/li")).getText(),
+ "The credentials provided are incorrect");
+ }
+ @Test
+ public void testAlertRequiredFieldsInGiftCard() throws InterruptedException {
+ getDriver().get("https://demowebshop.tricentis.com/gift-cards");
+
+ getDriver().findElement(
+ By.xpath("//div[@data-productid='2']//div[@class='buttons']/input[@value='Add to cart']"))
+ .click();
+
+ Thread.sleep(3000);
+
+ getDriver().findElement(
+ By.cssSelector("input#add-to-cart-button-2.button-1.add-to-cart-button"))
+ .click();
+
+ Thread.sleep(3000);
+
+ Assert.assertTrue(getDriver().findElement(
+ By.cssSelector("div#bar-notification"))
+ .isDisplayed());
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div#bar-notification> p:nth-child(2)"))
+ .getText(), "Enter valid recipient name");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div#bar-notification> p:nth-child(3)"))
+ .getText(), "Enter valid recipient email");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div#bar-notification> p:nth-child(4)"))
+ .getText(), "Enter valid sender name");
+ Assert.assertEquals(getDriver().findElement(
+ By.cssSelector("div#bar-notification> p:nth-child(5)"))
+ .getText(), "Enter valid sender email");
+ }
+ @Test
+ public void testSearchDropdownItemsQuantity() {
+ getDriver().get("https://demowebshop.tricentis.com/");
+
+ getDriver().findElement(By.linkText("Search")).click();
+ getDriver().findElement(By.id("As")).click();
+
+ Assert.assertEquals(getDriver().findElements(By.cssSelector("select[id='Cid'] option")).size(), 13);
+ }
+ @Test
+ public void testSearchEmptyField() {
+ getDriver().get("https://demowebshop.tricentis.com/search");
+
+ getDriver().findElement(By.cssSelector("input[id='Q']")).sendKeys("");
+ getDriver().findElement(By.cssSelector("input[class~='search-button']")).click();
+ getDriver().findElement(By.id("As")).click();
+ getDriver().findElement(By.id("Isc")).click();
+ getDriver().findElement(By.id("Sid")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("[class='warning']")).getText().substring(12, 26),
+ "minimum length");
+ }
+ @Test
+ public void testOpeningComputersPage() throws InterruptedException {
+ getDriver().get("https://demowebshop.tricentis.com/");
+ getDriver().findElement(By.xpath("//a[@href = '/computers']")).click();
+ Thread.sleep(2000);
+ String resultText = getDriver().findElement(By.cssSelector(".page-title")).getText();
+
+ Assert.assertEquals(resultText, "Computers");
+ }
+ @Test
+ public void testDesktopSortByPriceLowToHigh() throws InterruptedException {
+ getDriver().get("https://demowebshop.tricentis.com/");
+ getDriver().findElement(By.xpath("//ul[@class='list' ]//li[@class='inactive']//a[@href='/computers']")).click();
+ Thread.sleep(2000);
+
+ getDriver().findElement(By.xpath("//ul[@class='sublist' ]//li[@class='inactive']//a[@href = '/desktops']")).click();
+ Thread.sleep(2000);
+
+ getDriver().findElement(By.id("products-orderby")).click();
+ getDriver().findElement(By.xpath("//option[text()='Price: Low to High']")).click();
+
+ List prices = getDriver().findElements(By.cssSelector(".prices .price"));
+ double prevPrice = Integer.MIN_VALUE;
+
+ for (WebElement priceElement : prices) {
+ String priceText = priceElement.getText().replace("$", "").replace(",", "");
+ double price = Double.parseDouble(priceText);
+
+ Assert.assertTrue(price >= prevPrice, "Prices are not sorted correctly");
+ prevPrice = price;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/GroupCarlthefogTest.java b/src/test/java/school/redrover/old/GroupCarlthefogTest.java
new file mode 100644
index 0000000..58563bc
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupCarlthefogTest.java
@@ -0,0 +1,293 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Ignore
+public class GroupCarlthefogTest extends BaseTest {
+
+ private final static String FULL_NAME = "John Smith";
+ private final static String EMAIL = "john.smith@gmail.com";
+ private final static String ADDRESS = "5th Ave, New York";
+ private final static String PERM_ADDRESS = "5th Ave, New York";
+
+ @Test
+ public void testSaucedemo() {
+ String expectedPageName = "Swag Labs";
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+ driver.findElement(By.id("user-name")).sendKeys("standard_user");
+ driver.findElement(By.id("password")).sendKeys("secret_sauce");
+ driver.findElement(By.id("login-button")).click();
+
+ String actualPageName = driver.findElement(By.xpath("//div[@class= 'app_logo']")).getText();
+
+ Assert.assertEquals(expectedPageName, actualPageName);
+ driver.quit();
+ }
+
+ @Test
+ public void testPageHeader() {
+ String expectedPageHeader1 = "99 Bottles of Beer";
+ String expectedPageHeader2 = "Welcome to 99 Bottles of Beer";
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.99-bottles-of-beer.net/");
+
+ String actualPageHeader1 = driver.findElement(By.xpath("//h1")).getText();
+ String actualPageHeader2 = driver.findElement(By.xpath("//div[@id='main']//h2")).getText();
+
+ Assert.assertEquals(expectedPageHeader1, actualPageHeader1);
+ Assert.assertEquals(expectedPageHeader2, actualPageHeader2);
+
+ driver.quit();
+ }
+
+ @Test
+ public void testElementsList() {
+ int expectedElementsQuantity = 6;
+ List expectedElementsHeader = new ArrayList<>(Arrays.asList(
+ "Elements",
+ "Forms",
+ "Alerts, Frame & Windows",
+ "Widgets",
+ "Interactions",
+ "Book Store Application"));
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/");
+
+ int actualElementsQuantity = driver.findElements(By.xpath("//div[@class='card-body']")).size();
+
+ List elementsHeaderList = driver.findElements(By.xpath("//div[@class='card-body']"));
+ List actualElementsHeader = WebElementsToString(elementsHeaderList);
+
+ Assert.assertEquals(expectedElementsQuantity, actualElementsQuantity);
+ Assert.assertEquals(expectedElementsHeader, actualElementsHeader);
+
+ driver.quit();
+ }
+
+ public static List WebElementsToString(List elementsHeaderList) {
+ List stringList = new ArrayList<>();
+ for (WebElement element : elementsHeaderList) {
+ stringList.add(element.getText());
+ }
+
+ return stringList;
+ }
+
+ @Test
+ public void testElementsButtonMenuList() {
+ int expectedMenuListQuantity = 9;
+ List expectedItemName = new ArrayList<>(Arrays.asList(
+ "Text Box",
+ "Check Box",
+ "Radio Button",
+ "Web Tables",
+ "Buttons",
+ "Links",
+ "Broken Links - Images",
+ "Upload and Download",
+ "Dynamic Properties"));
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/");
+
+ driver.findElement(By.xpath("//div[@id='app']/div/div/div[2]/div/div[1]/div/div[1]")).click();
+ String currentURL = driver.getCurrentUrl();
+
+ int actualMenuListQuantity = driver.findElements(By.xpath("//div[@class='element-list collapse show']//li"))
+ .size();
+ List elementsHeaderList = driver.findElements(By.xpath("//div[@class='element-list collapse show']//li"));
+ List actualItemName = WebElementsToString(elementsHeaderList);
+
+ Assert.assertTrue(currentURL.contains("elements"));
+ Assert.assertEquals(expectedMenuListQuantity, actualMenuListQuantity);
+ Assert.assertEquals(expectedItemName, actualItemName);
+
+ driver.quit();
+ }
+
+ @Test
+ public void testLibrary() {
+
+ String expectedHeader1 = "For Adults";
+ String expectedHeader2 = "Kids Recommended";
+
+ getDriver().get("https://www.olathelibrary.org/");
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ WebElement servicesTab = getDriver().findElement(By.xpath("//a[text()='Services']"));
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(servicesTab).build().perform();
+
+ getDriver().findElement(By.xpath("//a[text()='Adult Book Recommendations']")).click();
+ WebElement header1 = getDriver().findElement(By.xpath("//header[@id='widget_6876_11653_2227']"));
+ String actualHeader1 = header1.getText();
+
+ Assert.assertEquals(actualHeader1, expectedHeader1);
+
+ WebElement kidsTab = getDriver().findElement(By.xpath("//a[text()='Kids']"));
+ actions.moveToElement(kidsTab).build().perform();
+
+ getDriver().findElement(By.xpath("//a[text()='Kids Recommended']")).click();
+ WebElement header2 = getDriver().findElement(By.xpath("//header[@id='widget_4280_11723_2315']"));
+ String actualHeader2 = header2.getText();
+
+ Assert.assertEquals(actualHeader2, expectedHeader2);
+ }
+
+ @Test
+ public void testMortgagePage() {
+
+ getDriver().get("https://www.bankofamerica.com/");
+
+ getDriver().findElement(By.xpath("//a[@id='navHomeLoans']")).click();
+ getDriver().findElement(By.xpath("//a[@id='mortgage']")).click();
+
+ Assert.assertTrue(getDriver().findElement(By.xpath("//h1[@id='skip-to-h1']")).getText().contains("Mortgage"));
+ }
+
+ @Test
+ public void purchaseItemTest() {
+
+ getDriver().get("https://qa-practice.netlify.app");
+
+ getDriver().findElement(By.id("products-list")).click();
+ getDriver().findElement(By.xpath("//div[@class='shop-item-details']/button")).click();
+ getDriver().findElement(By.xpath("//button[text()='PURCHASE']")).click();
+ String value = getDriver().findElement(By.id("message")).getText();
+
+ Assert.assertEquals(value, "Congrats! Your order of $905.99 has been registered!");
+ }
+
+ @Test
+ public void testExpandtesting() {
+
+ getDriver().get("https://practice.expandtesting.com/login");
+
+ getDriver().findElement(By.id("username")).sendKeys("practice");
+ getDriver().findElement(By.name("password")).sendKeys("SuperSecretPassword!");
+ getDriver().findElement(By.xpath("//button[@type='submit' and contains(text(),'Login')]")).click();
+
+ String actual = getDriver().findElement(By.id("flash")).getText();
+
+ Assert.assertEquals(actual, "You logged into a secure area!");
+ }
+
+ @Test
+
+ public void testLoginConduit() {
+ String userName = "Grechka" + Math.random() * 3;
+ String email = "Suyn@mail" + userName + ".ru";
+ String password = "W1234567" + Math.random() * 3;
+
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ driver.get("https://demo.realworld.io/#/register");
+
+ WebElement textBoxUserName = driver.findElement(By.xpath("//input[ @ng-model='$ctrl.formData.username']"));
+ textBoxUserName.sendKeys(userName);
+
+ WebElement textBoxEmail = driver.findElement(By.xpath("//input[@ng-model=\"$ctrl.formData.email\"]"));
+ textBoxEmail.sendKeys(email);
+
+ WebElement textBoxPassword = driver.findElement(By.xpath("//input[@ng-model=\"$ctrl.formData.password\"]"));
+ textBoxPassword.sendKeys(password);
+
+ WebElement buttons = driver.findElement(By.xpath("//button[@ng-bind='$ctrl.title']"));
+ buttons.click();
+
+ String actualUrl = driver.getCurrentUrl();
+ String expectedUrl = "https://demo.realworld.io/#/register";
+
+ Assert.assertEquals(actualUrl, expectedUrl, "URL не совпадает");
+ }
+
+ @Test
+ public void testTexBoxUseForm() {
+
+ String expectedHeader = "Text Box";
+
+ WebDriver driver = getDriver();
+ driver.manage().window().maximize();
+ driver.get("https://demoqa.com/text-box");
+
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ String actualHeader = driver.findElement(By.xpath("//div[@id='app']//h1")).getText();
+
+ driver.findElement(By.cssSelector("input#userName")).sendKeys(FULL_NAME);
+ driver.findElement(By.cssSelector("input#userEmail")).sendKeys(EMAIL);
+ driver.findElement(By.cssSelector("textarea#currentAddress")).sendKeys(ADDRESS);
+ driver.findElement(By.cssSelector("textarea#permanentAddress")).sendKeys(PERM_ADDRESS);
+
+ Actions act = new Actions(driver);
+ act.sendKeys(Keys.PAGE_DOWN).build().perform();
+ WebElement submitButton = driver.findElement(By.cssSelector("button#submit"));
+ submitButton.click();
+
+ WebElement expectedName = driver.findElement(By.cssSelector("p#name"));
+ WebElement expectedEmail = driver.findElement(By.cssSelector("p#email"));
+ WebElement expectedCurrentAddress = driver.findElement(By.cssSelector("p#currentAddress"));
+ WebElement expectedPermanentAddress = driver.findElement(By.cssSelector("p#permanentAddress"));
+
+ Assert.assertEquals(actualHeader, expectedHeader);
+ Assert.assertEquals(expectedName.getText(), "Name:" + FULL_NAME);
+ Assert.assertEquals(expectedEmail.getText(), "Email:" + EMAIL);
+ Assert.assertEquals(expectedCurrentAddress.getText(), "Current Address :" + ADDRESS);
+ Assert.assertEquals(expectedPermanentAddress.getText(), "Permananet Address :" + PERM_ADDRESS);
+
+ driver.quit();
+ }
+
+ @Test
+ public void testWikipediaSearch() {
+
+ getDriver().get("https://en.wikipedia.org");
+ getDriver().findElement(By.id("searchInput")).sendKeys("Selenium (software)");
+ getDriver().findElement(By.xpath("//button[contains(@Class, 'search-input')]")).click();
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(3000));
+
+ String expectedTitle = "Selenium (software) - Wikipedia";
+
+ String actualTitle = getDriver().getTitle();
+
+ Assert.assertEquals(actualTitle, expectedTitle, "Page title doesn't match expected title");
+ }
+
+ @Test
+ public void GoogleTranslateTest() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
+
+ getDriver().get("https://translate.google.com/");
+
+ Assert.assertEquals(getDriver().getTitle().toLowerCase(), "google переводчик");
+
+ WebElement inputField = getDriver().findElement(By.xpath("//textarea"));
+
+ inputField.sendKeys("Привет");
+
+ WebElement translateToEnglish = getDriver().findElement(By.xpath("(//span[contains(text(), 'английский')])[2]/ancestor::button"));
+
+ translateToEnglish.click();
+
+ WebElement translationResult = getDriver().findElement(By.xpath("//span[@lang='en']"));
+
+ Assert.assertEquals(translationResult.getText(), "Hello");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/GroupCompanionsTest.java b/src/test/java/school/redrover/old/GroupCompanionsTest.java
new file mode 100644
index 0000000..0824674
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupCompanionsTest.java
@@ -0,0 +1,84 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class GroupCompanionsTest extends BaseTest {
+ @Test
+ public void testExp86() {
+ WebDriver driver = getDriver();
+ driver.get("https://exp86.ru/");
+
+ WebElement textBox = driver.findElement(By.name("q"));
+ textBox.sendKeys("Hello world!");
+
+// How find element "Личный кабинет"
+ WebElement registrationHrev = driver.findElement(By.linkText("Личный кабинет"));
+ registrationHrev.click();
+
+ WebElement text = driver.findElement(By.className("form_default_star"));
+ String value = text.getText();
+
+ Assert.assertEquals("* обязательные поля для заполнения", value);
+ }
+
+ @Test
+ public void testFindElement() {
+
+ WebDriver driver = getDriver();
+ driver.get("https://exp86.ru");
+
+ WebElement test = driver.findElement(By.xpath("//input[@type='text']"));
+ test.sendKeys("Привет, мир!");
+
+ WebElement button = driver.findElement(By.xpath("//a[@href='/user/']"));
+ button.click();
+
+ WebElement string = driver.findElement(By.className("form_default_star"));
+ String result = string.getText();
+
+ Assert.assertEquals("* обязательные поля для заполнения", result);
+
+ }
+
+ @Test
+ public void testKg312(){
+ WebDriver driver = getDriver();
+ driver.get("https://312.kg/");
+
+ WebElement buttonBlog = driver.findElement(By.linkText("Знаете ли Вы?"));
+ buttonBlog.click();
+
+ WebElement text = driver.findElement(By.xpath("/html/body/div[1]/div/div/div/section/h1"));
+ String value = text.getText();
+
+ Assert.assertEquals("Блог", value);
+ }
+
+ @Test
+ public void testDZ() throws InterruptedException {
+ WebDriver driver = getDriver();
+ driver.get("https://exp86.ru/");
+
+ WebElement text = driver.findElement(By.name("q"));
+ text.sendKeys("Hello world");
+
+
+ WebElement button = driver.findElement(By.name("Поиск"));
+ button.click();
+
+
+ WebElement linc = driver.findElement(By.className("notetext"));
+ String result = linc.getText();
+
+ Assert.assertEquals(result, "К сожалению, на ваш поисковый запрос ничего не найдено.");
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupFlagmanTest.java b/src/test/java/school/redrover/old/GroupFlagmanTest.java
new file mode 100644
index 0000000..aeee3ac
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupFlagmanTest.java
@@ -0,0 +1,32 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class GroupFlagmanTest extends BaseTest {
+
+ @Test
+ public void testSauseDemoLoginForm() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ String title = getDriver().getTitle();
+ Assert.assertEquals(title, "Swag Labs");
+
+ WebElement userName = getDriver().findElement(By.name("user-name"));
+ userName.sendKeys("standard_user");
+
+ WebElement password = getDriver().findElement(By.name("password"));
+ password.sendKeys("secret_sauce");
+
+ WebElement loginButton = getDriver().findElement(By.name("login-button"));
+ loginButton.click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://www.saucedemo.com/inventory.html");
+ }
+
+}
diff --git a/src/test/java/school/redrover/old/GroupForwardTest.java b/src/test/java/school/redrover/old/GroupForwardTest.java
new file mode 100644
index 0000000..131fb40
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupForwardTest.java
@@ -0,0 +1,64 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.util.concurrent.TimeUnit;
+
+@Ignore
+public class GroupForwardTest extends BaseTest {
+
+ @Test
+ public void testCostco() {
+
+ getDriver().get("https://www.costco.com/");
+ getDriver().findElement(By.xpath("//*[@id='search-field']")).sendKeys("apple");
+ getDriver().findElement(By.xpath("//*[@id='search-field']")).sendKeys(Keys.ENTER);
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//*[@id='crumbs_ul']/li[2]/span")).getText(), "Apple Products");
+ }
+
+ @Test
+ public void testCostcoReturnToHomePage(){
+
+ getDriver().get("https://www.costco.com/apple-brand-showcase.html");
+ getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+ getDriver().findElement(By.xpath("//*[@id='crumbs_ul']/li[1]/a/span")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://www.costco.com/");
+ }
+//вопрос по тесту
+ @Ignore @Test
+ public void testdemoQAElements() {
+
+ getDriver().get("https://demoqa.com/");
+ getDriver().findElement(By.xpath("//h5[contains(text(), 'Elements')]")).click();
+ getDriver().findElement(By.xpath("//span[text() ='Text Box']")).click();
+ getDriver().findElement(By.id("userName")).sendKeys("Bob Forest");
+ getDriver().findElement(By.id("userEmail")).sendKeys("a@example.com");
+ getDriver().findElement(By.id("currentAddress")).sendKeys("8410 N. Rafael Rivera Way, Las Vegas, NV 89113");
+ getDriver().findElement(By.id("permanentAddress")).sendKeys("11011 W Charleston Blvd, Las Vegas, NV 89135");
+ getDriver().findElement(By.cssSelector("button#submit"));
+
+ Assert.assertTrue(getDriver().findElement(By.id("output")).isDisplayed());
+ Assert.assertEquals(getDriver().findElement(By.xpath("//p[@id='name']/text()['Bob Forest'][1]")),"Bob Forest");
+ }
+
+ @Test
+ public void testVenetianrearaurantsHappyHour() {
+
+ getDriver().get("https://www.venetianlasvegas.com/");
+ getDriver().findElement(By.xpath("//a[@data-navigation-title='Restaurants']")).click();
+ getDriver().findElement(By.xpath("//a [contains(text(), 'Happy')]")).click();
+ getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+ String text = getDriver().findElement(By.xpath("//div[@class='mod-restaurant-browse-hero']//h1")).getText();
+
+ Assert.assertTrue(getDriver().findElement(By.xpath("//div[@class='mod-restaurant-browse-hero']")).isDisplayed());
+ Assert.assertEquals(text, "Happy Hour");
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/GroupHollyGuacamoleTest.java b/src/test/java/school/redrover/old/GroupHollyGuacamoleTest.java
new file mode 100644
index 0000000..60576f4
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupHollyGuacamoleTest.java
@@ -0,0 +1,228 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.util.*;
+
+@Ignore
+public class GroupHollyGuacamoleTest extends BaseTest {
+ private static final String BASE_URL = "https://www.saucedemo.com/";
+ private static final String STANDARD_USER = "standard_user";
+ private static final String LOCKED_OUT_USER = "locked_out_user";
+ private static final String PROBLEM_USER = "problem_user";
+ private static final String ERROR_USER = "error_user";
+ private static final String VISUAL_USER = "visual_user";
+ private static final String PASSWORD = "secret_sauce";
+ private static final String CART_PAGE = "//a[@class='shopping_cart_link']";
+ private static final String BACKPACK_REMOVE_BUTTON = "//button[@id='remove-sauce-labs-backpack']";
+
+ public void login(String login, String password){
+ getDriver().get(BASE_URL);
+ getDriver().findElement(By.xpath("//input[@id='user-name']")).sendKeys(login);
+ getDriver().findElement(By.xpath("//input[@id='password']")).sendKeys(password);
+ getDriver().findElement(By.xpath("//input[@id='login-button']")).click();
+ }
+
+ @Test
+ public void testLoginSuccess(){
+ String expectedResult = BASE_URL + "inventory.html";
+ login(STANDARD_USER, PASSWORD);
+ String actualResult = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testCheckAmountItems() throws InterruptedException {
+ int expectedResult = 6;
+ login(STANDARD_USER, PASSWORD);
+ Thread.sleep(1000);
+ List items = getDriver().findElements(By.xpath("//div[@class='inventory_item']"));
+ int actualResult = items.size();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testAddItemToTheCard(){
+ boolean expectedResult = true;
+ login(STANDARD_USER, PASSWORD);
+ getDriver().findElement(By.xpath("//button[@id='add-to-cart-sauce-labs-bike-light']")).click();
+ getDriver().findElement(By.xpath(CART_PAGE)).click();
+ boolean actualResult = getDriver().findElement(By.linkText("Sauce Labs Bike Light")).isDisplayed();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testRemoveItemFromTheCart(){
+ login(STANDARD_USER, PASSWORD);
+ getDriver().findElement(By.xpath("//button[@id='add-to-cart-sauce-labs-backpack']")).click();
+ getDriver().findElement(By.xpath(CART_PAGE)).click();
+ getDriver().findElement(By.linkText("Sauce Labs Backpack")).isDisplayed();
+ getDriver().findElement(By.xpath(BACKPACK_REMOVE_BUTTON)).click();
+ boolean yestCho;
+ yestCho = getDriver().findElements(By.xpath(BACKPACK_REMOVE_BUTTON)).isEmpty();
+
+ Assert.assertTrue(yestCho);
+ }
+
+ @Test
+ public void testLoginSaucedemo () {
+ getDriver().get(BASE_URL);
+
+ getDriver().findElement(By.xpath("//input[@data-test='username']")).sendKeys("standard_user");
+ getDriver().findElement(By.xpath("//input[@data-test='password']")).sendKeys("secret_sauce");
+ getDriver().findElement(By.xpath("//input[@data-test='login-button']")).click();
+
+ String actual = getDriver().findElement(By.xpath("//span[@class='title']")).getText();
+
+ Assert.assertEquals(actual, "Products");
+ }
+
+ @Test
+ public void testLockedOutUser() {
+ String expectedResult = "Epic sadface: Sorry, this user has been locked out.";
+
+ login(LOCKED_OUT_USER, PASSWORD);
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//div[@class='error-message-container error']")).getAttribute("textContent"), expectedResult);
+ }
+
+ @Test
+ public void testProblemUser() {
+ login(PROBLEM_USER, PASSWORD);
+
+ WebElement imageSourceList = getDriver().findElement(By.xpath("//div[@class='inventory_list']/div/div/a/img"));
+ String actualResult = imageSourceList.getAttribute("src");
+
+ getDriver().findElement(By.xpath("//div[text()='Sauce Labs Backpack']")).click();
+ WebElement imageSourceItem = getDriver().findElement(By.xpath("//img[@alt='Sauce Labs Fleece Jacket']"));
+ String expectedResult = imageSourceItem.getAttribute("src");
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testErrorUser() throws InterruptedException {
+ login(ERROR_USER, PASSWORD);
+
+ getDriver().findElement(By.xpath("//button[@name='add-to-cart-sauce-labs-backpack']")).click();
+ WebElement removeButton = getDriver().findElement(By.xpath("//button[@name='remove-sauce-labs-backpack']"));
+ removeButton.getText();
+
+ Thread.sleep(1000);
+ removeButton.click();
+
+ Assert.assertEquals(removeButton.getText(), "Add to cart");
+ }
+
+ @Test
+ public void testVisualUser() {
+ String expectedRes = "10px";
+ login(VISUAL_USER, PASSWORD);
+
+ WebElement cssAttribute = getDriver().findElement(By.xpath("//div[@id='shopping_cart_container']"));
+ String actualRes = cssAttribute.getCssValue("top");
+
+ Assert.assertEquals(actualRes, expectedRes);
+ }
+
+ @Test
+ public void testProductPrice() {
+ getDriver().get("https://academybugs.com/find-bugs/");
+ List allProducts = getDriver().findElements(By.xpath("//li[@class='ec_product_li']"));
+ for (int i = 0; i < allProducts.size(); i++) {
+ String id = allProducts.get(i).getAttribute("id");
+ boolean isVisible = allProducts.get(i).findElement(By.xpath("//li[@id='"+ id + "']//span[@class='ec_price_type1']")).isDisplayed();
+
+ Assert.assertTrue(isVisible);
+ }
+ }
+
+ @Test
+ public void testSortZtoA() {
+ login(STANDARD_USER, PASSWORD);
+
+ List productsNamesElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-name']"));
+ List namesText = new ArrayList<>();
+ for (int i = 0; i < productsNamesElements.size(); i++) {
+ namesText.add(productsNamesElements.get(i).getText());
+ }
+ Collections.sort(namesText, Collections.reverseOrder());
+ List expected = new ArrayList<>(namesText);
+
+ getDriver().findElement(By.xpath("//option[@value='za']")).click();
+
+ productsNamesElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-name']"));
+ List actualResult = new ArrayList<>();
+ for (int i = 0; i < productsNamesElements.size(); i++) {
+ actualResult.add(productsNamesElements.get(i).getText());
+ }
+
+ Assert.assertEquals(actualResult, expected);
+ }
+
+ @Test
+ public void testSortPriceLowtoHigh() {
+ login(STANDARD_USER, PASSWORD);
+
+ List productsPriceElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-price']"));
+ List pricesText = new ArrayList<>();
+ for (WebElement priceElement : productsPriceElements) {
+ String temp = priceElement.getText().substring(1);
+ pricesText.add(Double.parseDouble(temp));
+ }
+ Collections.sort(pricesText);
+
+ List expected = new ArrayList<>(pricesText.size());
+ for (Double element: pricesText ) {
+ String temp = "$" + element;
+ expected.add(temp);
+ }
+
+ getDriver().findElement(By.xpath("//option[@value='lohi']")).click();
+
+ productsPriceElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-price']"));
+ List actualResult = new ArrayList<>();
+ for (int i = 0; i < productsPriceElements.size(); i++) {
+ actualResult.add(productsPriceElements.get(i).getText());
+ }
+
+ Assert.assertEquals(actualResult, expected);
+ }
+
+ @Test
+ public void testSortPriceHigToLow() {
+ login(STANDARD_USER, PASSWORD);
+
+ List productsPriceElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-price']"));
+ List pricesText = new ArrayList<>();
+ for (WebElement priceElement : productsPriceElements) {
+ String temp = priceElement.getText().substring(1);
+ pricesText.add(Double.parseDouble(temp));
+ }
+ pricesText.sort(Collections.reverseOrder());
+
+ List expected = new ArrayList<>(pricesText.size());
+ for (Double element: pricesText ) {
+ String temp = "$" + element;
+ expected.add(temp);
+ }
+
+ getDriver().findElement(By.xpath("//option[@value='hilo']")).click();
+
+ productsPriceElements = getDriver().findElements(By.xpath("//div[@data-test='inventory-item-price']"));
+ List actualResult = new ArrayList<>();
+ for (int i = 0; i < productsPriceElements.size(); i++) {
+ actualResult.add(productsPriceElements.get(i).getText());
+ }
+
+ Assert.assertEquals(actualResult, expected);
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupItFriendlyTest.java b/src/test/java/school/redrover/old/GroupItFriendlyTest.java
new file mode 100644
index 0000000..f69c269
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupItFriendlyTest.java
@@ -0,0 +1,36 @@
+package school.redrover.old;
+
+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;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class GroupItFriendlyTest {
+ @Test
+ public void testLoginSaucedemo () {
+ WebDriver driver = new ChromeDriver(new ChromeOptions());
+
+ driver.get("https://www.saucedemo.com");
+
+ WebElement usernameField = driver.findElement(By.id("user-name"));
+ usernameField.sendKeys("standard_user");
+
+ WebElement passwordField = driver.findElement(By.id("password"));
+ passwordField.sendKeys("secret_sauce");
+
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+
+ WebElement header = driver.findElement(By.className("app_logo"));
+
+ Assert.assertEquals(header.getText(), "Swag Labs");
+ driver.quit();
+
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupJavaAutoQARRSchoolTest.java b/src/test/java/school/redrover/old/GroupJavaAutoQARRSchoolTest.java
new file mode 100644
index 0000000..58df384
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupJavaAutoQARRSchoolTest.java
@@ -0,0 +1,250 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.interactions.Action;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Paths;
+import java.time.Duration;
+
+@Ignore
+public class GroupJavaAutoQARRSchoolTest extends BaseTest {
+ protected WebElement waitForElement(By locator) {
+ return new WebDriverWait(getDriver(), Duration.ofSeconds(10))
+ .until(ExpectedConditions.visibilityOfElementLocated(locator));
+ }
+
+ @Test
+ public void testReturnToHomePageFromInventoryDetailsCard() {
+ getDriver().get("https://www.saucedemo.com");
+
+ getDriver().findElement(By.name("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.name("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.name("login-button")).click();
+
+ WebElement inventoryName = getDriver().findElement(By.xpath("//div[text() = 'Sauce Labs Bike Light']"));
+ inventoryName.click();
+
+ WebElement backToProductBtn = getDriver().findElement(By.xpath("//button[@id = 'back-to-products']"));
+ backToProductBtn.click();
+
+ WebElement headerProductsOnTheHomePage = getDriver().findElement(By.xpath("//span[text() = 'Products']"));
+ String value = headerProductsOnTheHomePage.getText();
+
+ Assert.assertEquals(value, "Products");
+ }
+ @Test
+ public void testDemoQAPracticeForm(){
+ getDriver().get("https://demoqa.com/automation-practice-form");
+
+ WebElement firstName = waitForElement(By.id("firstName"));
+ firstName.sendKeys("Bob");
+
+ getDriver().findElement(By.xpath("//input[@id='lastName']")).sendKeys("Boboc");
+ getDriver().findElement(By.xpath("//input[@id='userEmail']")).sendKeys("test@gmail.com");
+ getDriver().findElement(By.xpath("//input[@id='userNumber']")).sendKeys("1234567890");
+ getDriver().findElement(By.xpath("//input[@id='gender-radio-1']/following-sibling::label['::after']")).click();
+
+ ((JavascriptExecutor) getDriver()).executeScript("window.scrollTo(0, 1600)");
+ getDriver().findElement(By.id("submit")).click();
+
+ WebElement title = waitForElement(By.id("example-modal-sizes-title-lg"));
+ String value = title.getText();
+ Assert.assertEquals(value, "Thanks for submitting the form");
+ }
+
+ @Test
+ public void testTasksAreaWithDoubleclick() {
+ getDriver().get("https://thecode.media/");
+
+ WebElement searchArea = getDriver().findElement(By.className("tab-questions"));
+
+ Action myAction = new Actions(getDriver()).doubleClick(searchArea).build();
+ myAction.perform();
+
+ String foundText = waitForElement(By.xpath("(//h1[@class='search__title'])")).getText();
+ Assert.assertEquals(foundText, "Как решить");
+ }
+
+ @Test
+ public void testCheckTextField() {
+ getDriver().get("https://thecode.media/");
+
+ WebElement searchButton = waitForElement(By.className("heading-search__open"));
+ searchButton.click();
+
+ WebElement searchText = waitForElement(By.className("heading-search__input"));
+ searchText.sendKeys("Api");
+
+ searchButton.click();
+
+ String foundText = waitForElement(By.className("search__title")).getText();
+ Assert.assertEquals(foundText,"api");
+ }
+
+ public void checkTable(String key, String value) {
+ WebElement tableWithResult = waitForElement(By.cssSelector(".table-responsive"));
+
+ WebElement cellWithKey = tableWithResult.findElement(By.xpath(".//*[contains(text(), '" + key + "')]"));
+
+ String parentXpath = "./..";
+ WebElement parentElement = cellWithKey.findElement(By.xpath(parentXpath));
+ boolean hasValue = parentElement.getText().contains(value);
+
+ if (!hasValue) {
+ throw new AssertionError("Expected text not found: " + value);
+ }
+ }
+
+ public void setDate(String year, String month, String day) {
+ WebElement selectYearElement = getDriver().findElement(By.className("react-datepicker__year-select"));
+ Select selectYear = new Select(selectYearElement);
+ selectYear.selectByVisibleText(year);
+
+ WebElement selectMonthElement = getDriver().findElement(By.className("react-datepicker__month-select"));
+ Select selectMonth = new Select(selectMonthElement);
+ selectMonth.selectByVisibleText(month);
+
+ String daySelector = String.format(".react-datepicker__day.react-datepicker__day--0%s:not(.react-datepicker__day--outside-month)", day);
+ WebElement dayElement = getDriver().findElement(By.cssSelector(daySelector));
+ dayElement.click();
+ }
+ @Test
+ void testAllFormFieldsAreFill() throws URISyntaxException, FileNotFoundException {
+ getDriver().get("https://demoqa.com/automation-practice-form");
+
+ ((JavascriptExecutor) getDriver()).executeScript("$('#fixedban').remove()");
+ ((JavascriptExecutor) getDriver()).executeScript("$('footer').remove()");
+
+ WebElement inputFirstName = waitForElement(By.id("firstName"));
+ inputFirstName.sendKeys("test");
+ String firstName = inputFirstName.getText();
+
+ WebElement inputLastName = waitForElement(By.id("lastName"));
+ inputLastName.sendKeys("test");
+ String lastName = inputLastName.getText();
+
+ WebElement inputUserEmail = waitForElement(By.id("userEmail"));
+ inputUserEmail.sendKeys("test@test.ru");
+ String userEmail = inputUserEmail.getText();
+
+ String gender = "Female";
+ WebElement radioGender = waitForElement(By.xpath("//label[@class='custom-control-label' and contains(text(), '" + gender + "')]"));
+ radioGender.click();
+
+ WebElement inputUserNumber = waitForElement(By.id("userNumber"));
+ inputUserNumber.sendKeys("3752912312");
+ String userMobile = inputUserNumber.getText();
+
+ WebElement inputCalendar = waitForElement(By.id("dateOfBirthInput"));
+ inputCalendar.click();
+ setDate("1991", "December", "27");
+ String userBirthDate = inputCalendar.getText();
+
+ WebElement inputSubjects = waitForElement(By.id("subjectsInput"));
+ inputSubjects.sendKeys("English");
+ inputSubjects.sendKeys(Keys.ENTER);
+ String subjects = inputSubjects.getText();
+
+ String hobbies = "Reading";
+ WebElement checkboxHobbies = waitForElement(By.xpath("//label[@class='custom-control-label' and contains(text(), '" + hobbies + "')]"));
+ checkboxHobbies.click();
+
+ WebElement inputUploadPicture = waitForElement(By.id("uploadPicture"));
+ URL resourceUrl = getClass().getClassLoader().getResource("1.jpg");
+ if (resourceUrl != null) {
+ String pathToFile = Paths.get(resourceUrl.toURI()).toFile().getAbsolutePath();
+ inputUploadPicture.sendKeys(pathToFile);
+ } else {
+ throw new FileNotFoundException("Resource not found: 1.jpg");
+ }
+
+ WebElement textAreaCurrentAddress = waitForElement(By.id("currentAddress"));
+ textAreaCurrentAddress.sendKeys("221B Baker Street");
+ String currentAddress = textAreaCurrentAddress.getText();
+
+ WebElement selectState = waitForElement(By.id("react-select-3-input"));
+ selectState.sendKeys("NCR");
+ selectState.sendKeys(Keys.ENTER);
+ String state = selectState.getText();
+
+ WebElement selectCity = waitForElement(By.id("react-select-4-input"));
+ selectCity.sendKeys("Gurgaon");
+ selectCity.sendKeys(Keys.ENTER);
+ String city = selectCity.getText();
+
+ WebElement buttonSendForm = waitForElement(By.id("submit"));
+ buttonSendForm.click();
+ String STUDENT_NAME = "Student Name",
+ STUDENT_EMAIL = "Student Email",
+ STUDENT_GENDER = "Gender",
+ STUDENT_MOBILE = "Mobile",
+ STUDENT_BIRTH = "Date of Birth",
+ STUDENT_SUBJECTS = "Subjects",
+ STUDENT_HOBBIES = "Hobbies",
+ STUDENT_PICTURE = "Picture",
+ STUDENT_ADDRESS = "Address",
+ STUDENT_STATE_AND_CITY = "State and City";
+
+ checkTable(STUDENT_NAME, firstName);
+ checkTable(STUDENT_NAME, lastName);
+ checkTable(STUDENT_EMAIL, userEmail);
+ checkTable(STUDENT_GENDER, gender);
+ checkTable(STUDENT_MOBILE, userMobile);
+ checkTable(STUDENT_BIRTH, userBirthDate);
+ checkTable(STUDENT_SUBJECTS, subjects);
+ checkTable(STUDENT_HOBBIES, hobbies);
+ checkTable(STUDENT_PICTURE, "1.jpg");
+ checkTable(STUDENT_ADDRESS, currentAddress);
+ checkTable(STUDENT_STATE_AND_CITY, state);
+ checkTable(STUDENT_STATE_AND_CITY, city);
+ }
+
+ @Test
+ public void testAuthorizationVprokat() {
+ getDriver().get("https://vprokat.online/");
+
+ getDriver().findElement(By.cssSelector("a[aria-label='Профиль']")).click();
+
+ getDriver().findElement(By.cssSelector("[autocomplete=email]")).sendKeys("1716.06+111@gmail.com");
+ getDriver().findElement(By.cssSelector("[autocomplete=current-password]")).sendKeys("parol123");
+ getDriver().findElement(By.cssSelector("div[role='dialog'] button[type='submit']")).click();
+
+ getDriver().findElement(By.cssSelector("a[aria-label='Профиль']")).click();
+
+ String sidebarMenu = waitForElement(By.cssSelector("main[footer='[object Object]'] p[class='mb-2']")).getText();
+ Assert.assertEquals(sidebarMenu, "1716.06+111@gmail.com");
+
+ getDriver().findElement(By.cssSelector("main[footer='[object Object]'] button[type='button']")).click();
+ }
+ @Test
+ public void addGiftCardToCart() {
+ WebDriver driver = getDriver();
+ String recipientName = "Very Good Person";
+ String senderName = "Very Generous Person";
+
+ driver.get("https://demowebshop.tricentis.com/");
+ driver.findElement(By.xpath("/html/body/div[4]/div[1]/div[4]/div[1]/div[1]/div[2]/ul/li[7]/a")).click();
+ driver.findElement(By.linkText("$100 Physical Gift Card")).click();
+ driver.findElement(By.className("recipient-name")).sendKeys(recipientName);
+ driver.findElement(By.className("sender-name")).sendKeys(senderName);
+ driver.findElement(By.xpath("//*[@id=\"add-to-cart-button-4\"]")).click();
+ driver.findElement(By.cssSelector("#topcartlink > a")).click();
+
+ String productName = driver.findElement(By.className("product-name")).getText();
+ String price = driver.findElement(By.className("unit-price")).getText();
+
+ Assert.assertEquals(productName, "$100 Physical Gift Card");
+ Assert.assertEquals(price, "100.00");
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupJavaExitCodeZeroTest.java b/src/test/java/school/redrover/old/GroupJavaExitCodeZeroTest.java
new file mode 100644
index 0000000..173872a
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupJavaExitCodeZeroTest.java
@@ -0,0 +1,734 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+import java.util.*;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+@Ignore
+public class GroupJavaExitCodeZeroTest extends BaseTest {
+ private static final String BASE_URL = "https://automationexercise.com";
+ private final static String HABR_URL = "https://habr.com/ru/search/";
+
+ private String getRandomEmail() {
+ int n = 15;
+ String AlphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ + "0123456789"
+ + "abcdefghijklmnopqrstuvxyz";
+
+ StringBuilder sb = new StringBuilder(n);
+
+ for (int i = 0; i < n; i++) {
+ int index = (int) (AlphaNumericString.length() * Math.random());
+ sb.append(AlphaNumericString.charAt(index));
+ }
+ return sb.toString() + "@gmail.com";
+ }
+
+ private int uniqueLetters(String word) {
+ String word2 = word.trim().toLowerCase();
+ String word3 = "";
+
+ HashMap charCountMap = new HashMap<>();
+
+ for (int i = 0; i < word2.length(); i++) {
+ char c = word2.charAt(i);
+ charCountMap.put(c, charCountMap.getOrDefault(c, 0) + 1);
+ }
+ for (char c : charCountMap.keySet()) {
+ if (charCountMap.get(c) == 1) {
+ word3 += c + "";
+ }
+
+ }
+ return word3.length();
+ }
+
+ private void openSauceDemo() {
+ getDriver().get(" https://www.saucedemo.com/");
+ }
+
+ private void clickFilterZtoA() {
+ getDriver().findElement(By.xpath("//option[@value='za']")).click();
+ }
+
+ private void loginToSauceDemo() {
+ WebElement username = getDriver().findElement(By.id("user-name"));
+ username.sendKeys("standard_user");
+ WebElement password = getDriver().findElement(By.id("password"));
+ password.sendKeys("secret_sauce");
+
+ getDriver().findElement(By.id("login-button")).click();
+ }
+
+ private void loginToSauceDemo(String userName, String userPassword) {
+ WebElement username = getDriver().findElement(By.id("user-name"));
+ username.sendKeys(userName);
+ WebElement password = getDriver().findElement(By.id("password"));
+ password.sendKeys(userPassword);
+
+ getDriver().findElement(By.id("login-button")).click();
+ }
+
+ private List getTexts(List list) {
+ List texts = new ArrayList<>();
+ for (WebElement element : list) {
+ texts.add(element.getText());
+ }
+ return texts;
+ }
+
+ @Test
+ public void testAllProductsNavigation() throws InterruptedException {
+ final String expectedProductsUrl = "https://automationexercise.com/products";
+ final String expectedHeader = "ALL PRODUCTS";
+
+ getDriver().get(BASE_URL);
+
+ getDriver().findElement(By.xpath("//a[@href='/products']")).click();
+ Thread.sleep(1000);
+ if (getDriver().findElements(By.xpath("//ins[@class='adsbygoogle adsbygoogle-noablate']")).size() > 0) {
+ JavascriptExecutor jse = (JavascriptExecutor) getDriver();
+ jse.executeScript(
+ "const ads = document.getElementsByClassName('adsbygoogle adsbygoogle-noablate'); while (ads.length > 0) ads[0].remove();"
+ );
+
+ getDriver().findElement(By.xpath("//a[@href='/products']")).click();
+ }
+
+ Thread.sleep(2000);
+
+ final String currentUrl = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(currentUrl, expectedProductsUrl);
+
+ final String actualHeader = getDriver().findElement(By.xpath("//div[@class = 'features_items']/h2")).getText();
+
+ Assert.assertEquals(actualHeader, expectedHeader);
+ }
+
+ @Test
+ public void testFindArticle() throws InterruptedException {
+ final String TEST_TEXT = "RedRover School";
+ final String expectedResult = "Большая подборка ресурсов и сообществ для тестировщика";
+
+ getDriver().get(HABR_URL);
+ getDriver().manage().window().maximize();
+
+ WebElement textArea = getDriver().findElement(By.xpath("//input[@name='q']"));
+ textArea.sendKeys(TEST_TEXT);
+ textArea.sendKeys(Keys.RETURN);
+ Thread.sleep(2000);
+ String hrefXpath = "//article[@id='720526']/div[1]/h2/a[@href ='/ru/articles/720526/'][@class='tm-title__link']";
+ WebElement firstArticle = getDriver().findElement(By.xpath(hrefXpath));
+ String actualResult = firstArticle.getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testEightComponents() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ getDriver().get("https://www.selenium.dev/selenium/web/web-form.html");
+
+ WebElement textBox = getDriver().findElement(By.name("my-text"));
+ WebElement submitButton = getDriver().findElement(By.cssSelector("button"));
+ textBox.sendKeys("Selenium");
+ submitButton.click();
+ WebElement message = getDriver().findElement(By.id("message"));
+ String value = message.getText();
+
+ Assert.assertEquals("Received!", value);
+ }
+
+ @Test
+ public void testAllProductsNavigationYS() throws InterruptedException {
+ final String expectedProductsUrl = "https://automationexercise.com/products";
+ final String expectedHeader = "ALL PRODUCTS";
+
+ getDriver().get(BASE_URL);
+
+ getDriver().findElement(By.xpath("//a[@href='/products']")).click();
+ Thread.sleep(1000);
+ if (!getDriver().findElements(By.xpath("//ins[@class='adsbygoogle adsbygoogle-noablate']")).isEmpty()) {
+ JavascriptExecutor jse = (JavascriptExecutor) getDriver();
+ jse.executeScript(
+ "const ads = document.getElementsByClassName('adsbygoogle adsbygoogle-noablate'); while (ads.length > 0) ads[0].remove();"
+ );
+
+ getDriver().findElement(By.xpath("//a[@href='/products']")).click();
+ }
+
+ Thread.sleep(2000);
+
+ final String currentUrl = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(currentUrl, expectedProductsUrl);
+
+ final String actualHeader = getDriver().findElement(By.xpath("//div[@class = 'features_items']/h2")).getText();
+
+ Assert.assertEquals(actualHeader, expectedHeader);
+ }
+
+ @Test
+ void testVerifyScrollUpUsingArrowButtonAndScrollDown()
+ throws InterruptedException {
+
+ final String expectedSubscription = "SUBSCRIPTION";
+ final String expectedText = "Full-Fledged practice website for Automation Engineers";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ ((JavascriptExecutor) getDriver()).executeScript("window.scrollTo(0, document.body.scrollHeight)");
+ Thread.sleep(1000);
+ WebElement subscription = getDriver().findElement(By.xpath("//h2[contains(text(), 'Subscription')]"));
+
+ Assert.assertTrue(subscription.isDisplayed());
+ Assert.assertEquals(subscription.getText(), expectedSubscription);
+
+ getDriver().findElement(By.id("scrollUp")).click();
+ Thread.sleep(1000);
+
+ By xpath = By.xpath("//h2[contains(text(), '" + expectedText + "')]");
+ WebElement textElement = getDriver().findElement(xpath);
+
+ Assert.assertTrue(textElement.isDisplayed());
+ Assert.assertEquals(textElement.getText(), expectedText);
+ }
+
+ @Test(invocationCount = 1)
+ public void testSubscriptionInCartPage()
+ throws InterruptedException {
+
+ final String expectedTitle = "Automation Exercise";
+ final String expectedSubscription = "SUBSCRIPTION";
+ final String expectedText = "You have been successfully subscribed!";
+
+ getDriver().manage().window().maximize();
+ getDriver().get(BASE_URL);
+ Assert.assertEquals(getDriver().getTitle(), expectedTitle);
+
+ getDriver().findElement(By.xpath("//a[contains(text(), 'Cart')]")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), BASE_URL + "/view_cart");
+ ((JavascriptExecutor) getDriver()).executeScript("window.scrollTo(0, document.body.scrollHeight)");
+
+ Thread.sleep(1000);
+ WebElement subscription = getDriver().findElement(By.xpath("//h2[contains(text(), 'Subscription')]"));
+
+ Assert.assertTrue(subscription.isDisplayed());
+ Assert.assertEquals(subscription.getText(), expectedSubscription);
+
+ getDriver().findElement(By.id("susbscribe_email")).sendKeys("qwerty@gmail.com");
+ getDriver().findElement(By.id("subscribe")).click();
+
+ WebElement successMessage = getDriver().findElement(By.id("success-subscribe"));
+ Assert.assertTrue(successMessage.isDisplayed());
+ Assert.assertEquals(successMessage.getText(), expectedText);
+ }
+
+ @Test(invocationCount = 1)
+ public void testAddReviewOnProduct()
+ throws InterruptedException {
+
+ final String expected = "ALL PRODUCTS";
+ final String review = "WRITE YOUR REVIEW";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.xpath("//a[@href='/products']")).click();
+
+ Thread.sleep(1000);
+ new Actions(getDriver()).moveByOffset(50, 50).click().perform();
+ Thread.sleep(2000);
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), BASE_URL + "/products");
+
+ By products = By.xpath("//h2[contains(@class, 'title text-center') and text()='All Products']");
+
+ WebElement element = getDriver().findElement(products);
+ Assert.assertTrue(element.isDisplayed());
+ Assert.assertEquals(element.getText(), expected);
+
+ List cards = getDriver().findElements(By.xpath("//a[text()='View Product']"));
+
+ int randomIndex = new Random().nextInt(cards.size());
+ System.out.println(randomIndex);
+ WebElement randomCard = cards.get(randomIndex);
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript("arguments[0].scrollIntoView(true);", randomCard);
+
+ randomCard.click();
+
+ Thread.sleep(1000);
+ new Actions(getDriver()).moveByOffset(50, 50).click().perform();
+ Thread.sleep(2000);
+
+ By reviews = By.xpath("//li[@class='active']//a[@href='#reviews']");
+
+ WebElement webElement = getDriver().findElement(reviews);
+
+ Assert.assertTrue(webElement.isDisplayed());
+ Assert.assertEquals(webElement.getText(), review);
+
+ getDriver().findElement(By.id("name")).sendKeys("Jack");
+ getDriver().findElement(By.id("email")).sendKeys("test@gmail.com");
+ getDriver().findElement(By.id("review")).sendKeys("This is a test review.");
+
+ ((JavascriptExecutor) getDriver()).executeScript("window.scrollBy(0, 500);");
+
+ getDriver().findElement(By.id("button-review")).click();
+
+ By selector = By.cssSelector("#review-section .alert-success.alert span");
+ WebElement elementSelector = getDriver().findElement(selector);
+
+ String reviewMessage = "Thank you for your review.";
+ Assert.assertTrue(elementSelector.isDisplayed());
+ Assert.assertEquals(elementSelector.getText(), reviewMessage);
+ }
+
+ @Test
+ public void testContactUs() {
+ final String expectedMessage = "Success! Your details have been submitted successfully.";
+ final String name = "Tom";
+ final String subjectMessage = "Claim";
+ final String textMessage = "My problem is....";
+
+ getDriver().get(BASE_URL);
+ getDriver().findElement(By.xpath("//a[@href='/contact_us']")).click();
+ getDriver().findElement(By.xpath("//input[@placeholder ='Name']")).sendKeys(name);
+ getDriver().findElement(By.xpath("//input[@placeholder ='Email']")).sendKeys(getRandomEmail());
+ getDriver().findElement(By.xpath("//input[@placeholder ='Subject']")).sendKeys(subjectMessage);
+ getDriver().findElement(By.id("message")).sendKeys(textMessage);
+ getDriver().findElement(By.xpath("//input[@name ='submit']")).click();
+ getDriver().switchTo().alert().accept();
+ String actualMessage = getDriver().findElement(By.xpath("//div[@class='status alert alert-success']")).getText();
+
+ Assert.assertEquals(actualMessage, expectedMessage);
+ }
+
+ @Test
+ public void testFindWomenBootsPage() throws InterruptedException {
+ final String expectedElement = "Women'S Boots";
+ final String BASE_URL = "https://www.6pm.com/";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+ getDriver().findElement(By.xpath("//a[@href='/shoes']")).click();
+
+ Thread.sleep(3000);
+
+ getDriver().findElement(By.xpath("//li[1]/button")).click();
+ getDriver().findElement(By.xpath("//a[@data-eventvalue='S-NAV-WomensBoots']")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), BASE_URL
+ + "women-boots/CK_XARCz1wHAAQHiAgMBAhg.zso?s=isNew/desc/goLiveDate/desc/recentSalesStyle/desc/");
+
+ Thread.sleep(3000);
+
+ By womensBoots = By.xpath("//h1[@class='px-z']");
+ String actualElement = getDriver().findElement(womensBoots).getText();
+
+ Assert.assertEquals(actualElement, expectedElement);
+ }
+
+ @Test
+ public void testSignUpAndDeleteAccount()
+ throws InterruptedException {
+
+ final String expectedResultName = "Elizabeth";
+ final String expectedResult = "New User Signup!";
+ final String expectedCreated = "ACCOUNT CREATED!";
+ final String expectedDeleted = "ACCOUNT DELETED!";
+ final String expectedResultAccount = "ENTER ACCOUNT INFORMATION";
+
+ getDriver().manage().window().maximize();
+ getDriver().get(BASE_URL);
+
+ getDriver().findElement(By.linkText("Signup / Login")).click();
+
+ WebElement signupHeader = getDriver().findElement(By.xpath("//div[@class='signup-form']//h2"));
+
+ Assert.assertTrue(signupHeader.isDisplayed());
+ Assert.assertEquals(signupHeader.getText(), expectedResult);
+
+ getDriver().findElement(By.xpath("//input[@name='name']")).sendKeys("Elizabeth");
+ getDriver().findElement(By.xpath("//input[@data-qa='signup-email']")).sendKeys("alice%d@gmail.com".formatted(new Random().nextInt(10000)));
+ getDriver().findElement(By.xpath("//button[@data-qa='signup-button']")).click();
+
+ WebElement accountInfo = getDriver().findElement(By.xpath("//h2[@class='title text-center']"));
+
+ Assert.assertTrue(accountInfo.isDisplayed());
+ Assert.assertEquals(accountInfo.getText(), expectedResultAccount);
+
+ getDriver().findElement(By.id("newsletter")).click();
+ getDriver().findElement(By.id("id_gender1")).click();
+ getDriver().findElement(By.id("password")).sendKeys("password");
+ getDriver().findElement(By.id("first_name")).sendKeys("Jack");
+ getDriver().findElement(By.id("last_name")).sendKeys("Sparrow");
+ getDriver().findElement(By.id("company")).sendKeys("Pearl");
+ getDriver().findElement(By.id("address1")).sendKeys("East");
+ getDriver().findElement(By.id("address2")).sendKeys("India");
+ getDriver().findElement(By.id("country")).sendKeys("Caribbean");
+ getDriver().findElement(By.id("state")).sendKeys("Port Royal");
+ getDriver().findElement(By.id("city")).sendKeys("Jamaica");
+ getDriver().findElement(By.id("zipcode")).sendKeys("12345");
+ getDriver().findElement(By.id("mobile_number")).sendKeys("+380990909999");
+
+ WebElement createAccount = getDriver().findElement(By.cssSelector("button[data-qa='create-account']"));
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript("arguments[0].scrollIntoView(true);", createAccount);
+ createAccount.click();
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("b")).getText(), expectedCreated);
+
+ getDriver().findElement(By.linkText("Continue")).click();
+ new Actions(getDriver()).moveByOffset(50, 50).click().perform();
+ Thread.sleep(1000);
+
+ WebElement loginName = getDriver().findElement(By.xpath("//li/a/b"));
+
+ Assert.assertTrue(loginName.isDisplayed());
+ Assert.assertEquals(loginName.getText(), expectedResultName);
+
+ getDriver().findElement(By.linkText("Delete Account")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.cssSelector("b")).getText(), expectedDeleted);
+
+ getDriver().findElement(By.linkText("Continue")).click();
+ }
+
+ @Test
+ public void testAddToCartFromRecommendedItems()
+ throws InterruptedException {
+ getDriver().manage().window().maximize();
+ getDriver().get(BASE_URL);
+
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
+ Thread.sleep(1000);
+
+ WebElement recommendedItems = getDriver().findElement(By.xpath("//h2[contains(text(), 'recommended items')]"));
+
+ Assert.assertTrue(recommendedItems.isDisplayed());
+
+ getDriver().findElement(By.xpath("//a[@class='btn btn-default add-to-cart']")).click();
+ Thread.sleep(1000);
+ getDriver().findElement(By.partialLinkText("View Cart")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), BASE_URL + "/view_cart");
+ Assert.assertTrue(getDriver().findElement(By.xpath("//tr[@id='product-1']")).isDisplayed());
+ }
+
+ @Test
+ public void testForm() {
+ final String url = "https://demoqa.com/";
+ final String expectedTitleElementPage = "Please select an item from left to start practice.";
+ final String urlTextBoxPage = "https://demoqa.com/text-box";
+ final String userName = "Tom";
+ final String userEmail = "test@test.com";
+ final String expectedName = "Name:Tom";
+ final String expectedEmail = "Email:test@test.com";
+
+ getDriver().get(url);
+ getDriver().manage().window().maximize();
+ getDriver().findElement(By.xpath("//div[@class='card mt-4 top-card'][1]")).click();
+
+ String titleElementPage = getDriver().findElement(By.xpath("//div[@class='col-12 mt-4 col-md-6']"))
+ .getText()
+ .trim();
+
+ Assert.assertEquals(titleElementPage, expectedTitleElementPage);
+
+ getDriver().findElement(By.xpath("//ul//li[@id='item-0']/span[text()='Text Box']")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), urlTextBoxPage);
+
+ getDriver().findElement(By.cssSelector("#userName")).sendKeys(userName);
+ getDriver().findElement(By.cssSelector("#userEmail")).sendKeys(userEmail);
+ getDriver().findElement(By.cssSelector("#submit")).click();
+ String nameInForm = getDriver().findElement(By.cssSelector("div>p#name")).getText().trim();
+ String emailInForm = getDriver().findElement(By.cssSelector("div>p#email")).getText().trim();
+
+ Assert.assertEquals(nameInForm, expectedName);
+ Assert.assertEquals(emailInForm, expectedEmail);
+ }
+
+ @Test
+ public void testVerifyProductInCart() throws InterruptedException {
+ final String expectVerifyHomePage = "FEATURES ITEMS";
+ final String expectVerifyProductDetail = "Availability:";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ final String actualVerifyHomePage = getDriver().findElement(By.xpath("//h2[text()='Features Items']")).getText();
+
+ Assert.assertEquals(actualVerifyHomePage, expectVerifyHomePage);
+
+ List viewProductCards = getDriver().findElements(By.xpath("//a[text()='View Product']"));
+ final int randomElementIndex = ThreadLocalRandom.current().nextInt(viewProductCards.size());
+
+ WebElement randomViewProductCardButton = viewProductCards.get(randomElementIndex);
+
+ JavascriptExecutor jse = (JavascriptExecutor) getDriver();
+ jse.executeScript("arguments[0].scrollIntoView();", randomViewProductCardButton);
+ Thread.sleep(1000);
+
+ randomViewProductCardButton.click();
+ Thread.sleep(1000);
+ if (!getDriver().findElements(By.xpath("//ins[@class='adsbygoogle adsbygoogle-noablate']")).isEmpty()) {
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript(
+ "const ads = document.getElementsByClassName('adsbygoogle adsbygoogle-noablate'); while (ads.length > 0) ads[0].remove();"
+ );
+
+ randomViewProductCardButton.click();
+ }
+
+ final String actualVerifyProductDetail = getDriver().findElement(By.xpath("//b[text()='Availability:']")).getText();
+
+ Assert.assertEquals(actualVerifyProductDetail, expectVerifyProductDetail);
+
+ Thread.sleep(1000);
+
+ final String actualProductIsDisplayed = getDriver().findElement(By.xpath("//div[@class = \"product-information\"]//h2")).getText();
+
+ getDriver().findElement(By.xpath("//button[@type = \"button\"]")).click();
+ Thread.sleep(1000);
+ if (!getDriver().findElements(By.xpath("//ins[@class='adsbygoogle adsbygoogle-noablate']")).isEmpty()) {
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript(
+ "const ads = document.getElementsByClassName('adsbygoogle adsbygoogle-noablate'); while (ads.length > 0) ads[0].remove();"
+ );
+
+ getDriver().findElement(By.xpath("//button[@type = \"button\"]")).click();
+ }
+
+ getDriver().findElement(By.xpath("//a[@href = \"/view_cart\"]/u")).click();
+ Thread.sleep(1000);
+ if (!getDriver().findElements(By.xpath("//ins[@class='adsbygoogle adsbygoogle-noablate']")).isEmpty()) {
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript(
+ "const ads = document.getElementsByClassName('adsbygoogle adsbygoogle-noablate'); while (ads.length > 0) ads[0].remove();"
+ );
+
+ getDriver().findElement(By.xpath("//a[@href = \"/view_cart\"]/u")).click();
+ }
+ final String expectedProductIsDisplayed = getDriver().findElement(By.xpath("//td//h4//a")).getText();
+
+ Assert.assertEquals(expectedProductIsDisplayed, actualProductIsDisplayed);
+ }
+
+ @Test
+ public void testAuthorizationSaucedemoStandardUser() {
+ final String BASE_URL = "https://www.saucedemo.com/";
+ final String expectedLink = "https://www.saucedemo.com/inventory.html";
+ final String userName = "standard_user";
+ final String PASSWORD = "secret_sauce";
+ final String expectedLogoText = "Swag Labs";
+ final String expectedTitle = "Products";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ WebElement buttonText = getDriver().findElement(By.id("user-name"));
+ buttonText.sendKeys(userName);
+ WebElement buttonPassword = getDriver().findElement(By.id("password"));
+ buttonPassword.sendKeys(PASSWORD);
+ WebElement buttonSubmit = getDriver().findElement(By.id("login-button"));
+ buttonSubmit.click();
+ WebElement logoText = getDriver().findElement(By.xpath("//div[@class='app_logo']"));
+ String actualLogoText = logoText.getText();
+ WebElement title = getDriver().findElement(By.xpath("//span[@class='title']"));
+ String actualTitle = title.getText();
+ String actualLink = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(actualLink, expectedLink);
+ Assert.assertEquals(actualLogoText, expectedLogoText);
+ Assert.assertEquals(actualTitle, expectedTitle);
+
+ }
+
+ @Test
+ public void testAuthorizationSaucedemoLockedUser() {
+ final String BASE_URL = "https://www.saucedemo.com/";
+ final String userName = "locked_out_user";
+ final String PASSWORD = "secret_sauce";
+ final String expectedErrorText = "Epic sadface: Sorry, this user has been locked out.";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ WebElement buttonText = getDriver().findElement(By.id("user-name"));
+ buttonText.sendKeys(userName);
+ WebElement buttonPassword = getDriver().findElement(By.id("password"));
+ buttonPassword.sendKeys(PASSWORD);
+ WebElement buttonSubmit = getDriver().findElement(By.id("login-button"));
+ buttonSubmit.click();
+ WebElement errorText = getDriver().findElement(By.xpath("//h3[contains(text(),'Epic sadface')]"));
+ String actualErrorText = errorText.getText();
+ String actualLink = getDriver().getCurrentUrl();
+ WebElement userNameErrorImage = getDriver().findElement(By.xpath("//input[@id='user-name']/following-sibling::*"));
+ WebElement userLoginErrorImage = getDriver().findElement(By.xpath("//input[@id='password']/following-sibling::*"));
+ WebElement errorBanner = getDriver().findElement(By.xpath("//h3[@data-test='error']"));
+
+ Assert.assertEquals(actualLink, BASE_URL);
+ Assert.assertEquals(actualErrorText, expectedErrorText);
+ Assert.assertTrue(userNameErrorImage.isDisplayed());
+ Assert.assertTrue(userLoginErrorImage.isDisplayed());
+ Assert.assertTrue(errorBanner.isDisplayed());
+
+ }
+
+ @Test
+ public void testNamesOfNavigationBar() throws InterruptedException {
+ final String url = "https://openweathermap.org/";
+ final List expectedResult = List.of("Guide", "API", "Dashboard", "Marketplace", "Pricing",
+ "Maps", "Our Initiatives", "Partners", "Blog", "For Business", "Sign in", "Support", "FAQ", "How to start", "Ask a question");
+
+ getDriver().get(url);
+ getDriver().manage().window().maximize();
+
+ List listNamesOfNavbar = getDriver().findElements(By.xpath("//li[@id='desktop-menu']//li"));
+ List namesOfNavbar = new ArrayList<>();
+
+ for (WebElement element : listNamesOfNavbar) {
+ String text = element.getText();
+ if (!text.isEmpty()) {
+ namesOfNavbar.add(element.getText());
+ }
+ }
+
+ getDriver().findElement(By.cssSelector("#support-dropdown")).click();
+ Thread.sleep(2000);
+ List supportMenu = getDriver().findElements(By.cssSelector("#support-dropdown-menu>li"));
+
+ for (WebElement element : supportMenu) {
+ namesOfNavbar.add(element.getText());
+ }
+
+ Assert.assertEquals(namesOfNavbar, expectedResult);
+ }
+
+ @Test
+ public void testUniqueLetters() {
+
+ int expectedResult = 9;
+
+ getDriver().get("https://ru.wikipedia.org/wiki/%D0%94%D0%BE%D1%81%D1%82%D0%BE%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%87%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1%82%D1%8C");
+ WebElement heading = getDriver().findElement(By.xpath("//h1//span"));
+ int actualResult = uniqueLetters(heading.getText());
+
+ Assert.assertEquals(actualResult, expectedResult);
+ }
+
+ @Test
+ public void testFilterZtoA() {
+
+ openSauceDemo();
+
+ loginToSauceDemo();
+
+ clickFilterZtoA();
+ List productsNamesElements = getDriver().findElements(By.xpath("//div[@class='inventory_item_name '] "));
+ List productsNamesText = getTexts(productsNamesElements);
+
+ List expectedResult = new ArrayList<>(productsNamesText);
+
+ expectedResult.sort(Collections.reverseOrder());
+
+ Assert.assertEquals(productsNamesText, expectedResult);
+ }
+
+ @Test
+ public void testImageClickToProductCard() {
+
+ final String BASE_URL = "https://www.saucedemo.com/";
+ final String userName = "standard_user";
+ final String PASSWORD = "secret_sauce";
+ final String expectedLink = "https://www.saucedemo.com/inventory-item.html?id=4";
+
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ WebElement buttonText = getDriver().findElement(By.id("user-name"));
+ buttonText.sendKeys(userName);
+ WebElement buttonPassword = getDriver().findElement(By.id("password"));
+ buttonPassword.sendKeys(PASSWORD);
+ WebElement buttonSubmit = getDriver().findElement(By.id("login-button"));
+ buttonSubmit.click();
+ WebElement image = getDriver().findElement(By.xpath("//div/a[@id=\"item_4_img_link\"]"));
+ image.click();
+ String actualLink = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(actualLink, expectedLink);
+
+ }
+ @Test
+ public void testAddToCart() {
+
+ final String BASE_URL = "https://www.saucedemo.com/";
+ final String userName = "standard_user";
+ final String PASSWORD = "secret_sauce";
+ final String expectedLogoText = "Swag Labs";
+ final String expectedTitle = "Products";
+ final String expectedLink = "https://www.saucedemo.com/inventory-item.html?id=4";
+ final String expectedCartElement = "1";
+
+ getDriver().get(BASE_URL);
+ getDriver().manage().window().maximize();
+
+ WebElement buttonText = getDriver().findElement(By.id("user-name"));
+ buttonText.sendKeys(userName);
+ WebElement buttonPassword = getDriver().findElement(By.id("password"));
+ buttonPassword.sendKeys(PASSWORD);
+ WebElement buttonSubmit = getDriver().findElement(By.id("login-button"));
+ buttonSubmit.click();
+ WebElement image = getDriver().findElement(By.xpath("//div/a[@id=\"item_4_img_link\"]"));
+ image.click();
+ String actualLink = getDriver().getCurrentUrl();
+ getDriver().findElement(By.name("add-to-cart")).click();
+ WebElement cartElement = getDriver().findElement(By.xpath("//div[@id='shopping_cart_container']/a/span"));
+ String actualCartElement = cartElement.getText();
+
+ Assert.assertEquals(actualLink, expectedLink);
+ Assert.assertEquals(actualCartElement, expectedCartElement);
+
+ }
+
+// login https://www.saucedemo.com/
+// Авторизация используя некорректные данные (user, user)
+ @Test
+ public void testIncorrectLoginToSauceDemo() {
+ String expectedResult = "Epic sadface: Username and password do not match any user in this service";
+
+ openSauceDemo();
+ loginToSauceDemo("user", "user");
+
+ WebElement userNameErrorIcon = getDriver().findElement(By.xpath("//input[@id='user-name']/following-sibling::*"));
+ WebElement passwordErrorIcon = getDriver().findElement(By.xpath("//input[@id='password']/following-sibling::*"));
+ WebElement errorBanner = getDriver().findElement(By.xpath("//div[@class='error-message-container error']"));
+ WebElement errorMessage = getDriver().findElement(By.xpath("//h3"));
+ String errorMessageText = errorMessage.getText();
+
+ Assert.assertTrue(userNameErrorIcon.isDisplayed());
+ Assert.assertTrue(passwordErrorIcon.isDisplayed());
+ Assert.assertTrue(errorBanner.isDisplayed());
+ Assert.assertTrue(errorMessage.isDisplayed());
+ Assert.assertEquals(errorMessageText, expectedResult);
+ }
+}
diff --git a/src/test/java/school/redrover/old/GroupLearnForWinAK2024Test.java b/src/test/java/school/redrover/old/GroupLearnForWinAK2024Test.java
new file mode 100644
index 0000000..cd19ba3
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupLearnForWinAK2024Test.java
@@ -0,0 +1,225 @@
+package school.redrover.old;
+
+import org.openqa.selenium.*;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.awt.*;
+import java.awt.Dimension;
+import java.awt.event.InputEvent;
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import school.redrover.runner.BaseTest;
+
+import static org.testng.Assert.assertTrue;
+
+@Ignore
+public class GroupLearnForWinAK2024Test extends BaseTest {
+ private static final String LOGIN = "academic198405@gmail.com";
+ private static final String MY_ACCOUNT = "[aria-label='person']";
+ private static final String PASSWORD = "StateOf2024!";
+ private static final String URL = "https://www.trekbikes.com/us/en_US/";
+ private static final String SECOND_URL = "https://demoqa.com/";
+
+ @Test
+ public void testLoginSuccessful() {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ driver.get(URL);
+ driver.manage().window().maximize();
+ driver.findElement(By.cssSelector(MY_ACCOUNT)).click();
+ driver.findElement(By.cssSelector("span[data-v-27f1dc12]")).click();
+ driver.findElement(By.id("j_username")).sendKeys(LOGIN);
+ driver.findElement(By.id("j_password")).sendKeys(PASSWORD);
+ driver.findElement(By.xpath("//span[text()='Log in']")).click();
+ driver.findElement(By.cssSelector(MY_ACCOUNT)).click();
+
+ driver.findElement
+ (By.xpath("//button[@class='nav-utility-bar-control__button tippy-active']")).click();
+ WebElement logout = driver.findElement(By.xpath("//a[@content='Log out']"));
+ String actText = logout.getText();
+ String expText = "Log out";
+ Assert.assertEquals(actText, expText);
+ }
+
+ @Test
+ public void testVisibleSuperCaliberSLR982() throws AWTException, InterruptedException {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ driver.get(URL);
+ driver.manage().window().maximize();
+ driver.findElement(By.cssSelector(MY_ACCOUNT)).click();
+ driver.findElement(By.cssSelector("span[data-v-27f1dc12]")).click();
+ driver.findElement(By.id("j_username")).sendKeys(LOGIN);
+ driver.findElement(By.id("j_password")).sendKeys(PASSWORD);
+ driver.findElement(By.xpath("//span[text()='Log in']")).click();
+
+ driver.findElement(By.xpath("//a[@id='expandMountainBikesMainMenu-large']")).click();
+ driver.findElement(By.xpath("(//span[text()='Shop all mountain bikes'])[2]")).click();
+
+ Robot robot = new Robot();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ int centerX = 1160;
+ int centerY = 580;
+ robot.mouseMove(centerX, centerY);
+ TimeUnit.SECONDS.sleep(2);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+ WebElement element = driver.findElement(By.xpath("//h3[contains(text(), 'Fuel EXe 8 GX AXS T-Type')]"));
+ String fuelExeText = element.getText();
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ js.executeScript("arguments[0].scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });", element);
+ Assert.assertEquals(fuelExeText, "Fuel EXe 8 GX AXS T-Type");
+ }
+
+ @Test
+ public void testCheckMenuElement() {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ driver.get(SECOND_URL);
+ driver.manage().window().maximize();
+
+ WebElement element = driver.findElement(By.xpath("//*[text()='Book Store Application']"));
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ int subm = element.getLocation().getY();
+ for (int i = 0; i < subm; i += 20) {
+ js.executeScript("window.scrollTo(0, " + i + ")");
+ }
+
+ WebElement element1 = driver.findElement(By.xpath("//*[text()='Elements']"));
+ element1.click();
+
+ List expectedMenuItems = Arrays.asList(
+ "Text Box", "Check Box", "Radio Button", "Web Tables", "Buttons",
+ "Links", "Broken Links - Images", "Upload and Download", "Dynamic Properties"
+ );
+ WebElement menuList = driver.findElement(By.xpath("//ul[@class='menu-list']"));
+ String menuItemsText = menuList.getText();
+
+ for (String expectedItem : expectedMenuItems) {
+ assertTrue(menuItemsText.contains(expectedItem), "Меню не содержит элемент: " + expectedItem);
+ }
+ }
+
+ @Test
+ public void testCheckWeAreOnPracticeFormPage() {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ driver.get(SECOND_URL);
+ driver.manage().window().maximize();
+
+ driver.findElement(By.xpath("//h5[text()='Forms']")).click();
+ driver.findElement(By.xpath("//span[text()='Practice Form']")).click();
+
+ WebElement practiceFormTitle = driver.findElement(By.xpath("//span[text()='Practice Form']"));
+
+ assertTrue(practiceFormTitle.isDisplayed());
+ }
+
+ @Test
+ public void testCheckDataInput() throws InterruptedException {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+ String expectedText = "Thanks for submitting the form";
+
+ driver.get(SECOND_URL);
+ driver.manage().window().maximize();
+
+ driver.findElement(By.xpath("//h5[text()='Forms']")).click();
+ driver.findElement(By.xpath("//span[text()='Practice Form']")).click();
+
+ driver.findElement(By.xpath("//input[@placeholder='First Name']")).sendKeys("Artuom");
+ driver.findElement(By.xpath("//input[@id='lastName']")).sendKeys("Kudryashov");
+ WebElement email = driver.findElement(By.xpath("//input[@id='userEmail']"));
+ email.sendKeys("artuomkudryashov@gmail.com");
+ driver.findElement(By.xpath("//label[@for='gender-radio-1']")).click();
+ driver.findElement(By.xpath("//input[@placeholder='Mobile Number']")).sendKeys("6666666666");
+ driver.findElement(By.xpath("//input[@id='dateOfBirthInput']")).click();
+ driver.findElement(By.xpath("//select[@class='react-datepicker__year-select']")).click();
+ driver.findElement(By.xpath("//option[@value='2056']")).click();
+ driver.findElement(By.xpath("//select[@class='react-datepicker__month-select']")).click();
+ driver.findElement(By.xpath("//option[@value='7']")).click();
+ driver.findElement(By.xpath("//*[contains(@aria-label,' August 14th')]")).click();
+ driver.findElement(By.xpath("//label[@for='hobbies-checkbox-1']")).click();
+ driver.findElement(By.xpath("//textarea[@id='currentAddress']")).sendKeys("Gotham City, Wayne Manor");
+ WebElement submit = driver.findElement(By.xpath("//button[@id='submit']"));
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ int subm = submit.getLocation().getY();
+ for (int i = 0; i < subm; i += 20) {
+ js.executeScript("window.scrollTo(0, " + i + ")");
+ Thread.sleep(50);
+ }
+ submit.click();
+
+ WebElement thanks = driver.findElement(By.xpath("//div[text()='Thanks for submitting the form']"));
+ thanks.getText();
+ assertTrue(thanks.isDisplayed());
+
+ Assert.assertEquals(thanks.getText(), expectedText);
+ }
+
+ @Test
+ public void testChamplainValleyTrailIsMenu() throws InterruptedException {
+ WebDriver driver = getDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ driver.get("https://www.google.com/");
+ driver.manage().window().maximize();
+ WebElement search_field = driver.findElement(By.xpath("//textarea[@class='gLFyf']"));
+ search_field.sendKeys("Empire State Trail");
+ search_field.sendKeys(Keys.ENTER);
+ WebElement eST = driver.findElement(By.xpath("(//cite[text()='https://empiretrail.ny.gov'])[1]"));
+ eST.click();
+
+ WebElement viewMap = driver.findElement(By.xpath("//a[text()='View Map']"));
+
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ js.executeScript("arguments[0].scrollIntoView({ behavior:" +
+ " 'smooth', block: 'center', inline: 'center' });", viewMap);
+ viewMap.click();
+
+ WebElement hVGT = driver.findElement(By.xpath("//a[@data-trail='hudson-valley-greenway-trail']"));
+ WebElement eCT = driver.findElement(By.xpath("//a[@data-trail='erie-canalway-trail']"));
+ WebElement cVT = driver.findElement(By.xpath("//a[@data-trail='champlain-valley-trail']"));
+
+ WebElement insideNYCToP = driver.findElement(By.xpath("//h4[text()='New York City to Poughkeepsie']"));
+ String textInSideNYCToP = insideNYCToP.getText();
+ WebElement insideBtoR = driver.findElement(By.xpath("//h4[contains(text(), 'Rochester') and contains(text(), 'Buffalo')]"));
+ String textInSideBtoR = insideBtoR.getText();
+ WebElement inSideECT = driver.findElement(By.xpath("//h4[contains(text(), 'Albany') and contains(text(), 'Whitehall')]"));
+ String textInSideEct = inSideECT.getText();
+ List menuWays = driver.findElements(By.xpath("//div[@class='accordion']"));
+ for (WebElement menu : menuWays) {
+ boolean containsText = menu.getText().contains(textInSideNYCToP) ||
+ menu.getText().contains(textInSideBtoR) ||
+ menu.getText().contains(textInSideEct);
+ assertTrue(containsText, "Expected text not found in menu: " + menu.getText());
+ }
+ }
+ @Test
+ public void W3school1test() {
+ getDriver().get("https://www.w3schools.com/");
+
+ Assert.assertEquals(getDriver().getTitle(), "W3Schools Online Web Tutorials");
+
+ getDriver().findElement(By.id("search2")).sendKeys("HTML Tutorial");
+
+ getDriver().findElement(By.id("learntocode_searchbtn")).click();
+
+ Assert.assertEquals(getDriver().getTitle(), "HTML Tutorial");
+ }
+}
+
+
diff --git a/src/test/java/school/redrover/old/GroupQaTheBestTest.java b/src/test/java/school/redrover/old/GroupQaTheBestTest.java
new file mode 100644
index 0000000..6ee39df
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupQaTheBestTest.java
@@ -0,0 +1,28 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import java.time.Duration;
+
+import school.redrover.runner.BaseTest;
+
+
+@Ignore
+public class GroupQaTheBestTest extends BaseTest {
+ @Test
+ public void kmFirstTest() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
+
+ getDriver().get("https://automationintesting.online");
+ getDriver().findElement(By.id("name")).sendKeys("John Doe");
+ getDriver().findElement(By.id("email")).sendKeys("johndoe@gmail.com");
+ getDriver().findElement(By.id("phone")).sendKeys("12345678900");
+ getDriver().findElement(By.id("subject")).sendKeys("Test Subject");
+ getDriver().findElement(By.id("description")).sendKeys("Hello World Hello World");
+ getDriver().findElement(By.id("submitContact")).click();
+
+ Assert.assertEquals("Thanks for getting in touch John Doe!", getDriver().findElement(By.cssSelector(
+ "#root > div > div > div.row.contact > div:nth-child(2) > div > h2")).getText());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/GroupRedroverJava7Test.java b/src/test/java/school/redrover/old/GroupRedroverJava7Test.java
new file mode 100644
index 0000000..319ae6b
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupRedroverJava7Test.java
@@ -0,0 +1,295 @@
+package school.redrover.old;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+
+@Ignore
+public class GroupRedroverJava7Test extends BaseTest {
+
+ @Test
+ public void testSearch() {
+ getDriver().get("https://www.selenium.dev/selenium/web/web-form.html");
+
+ WebElement textBox = getDriver().findElement(By.name("my-text"));
+ textBox.sendKeys("Selenium");
+
+ WebElement submitButton = getDriver().findElement(By.cssSelector("button"));
+ submitButton.click();
+
+ WebElement message = getDriver().findElement(By.id("message"));
+ String value = message.getText();
+
+ Assert.assertEquals(value, "Received!");
+ }
+
+ @Test
+ public void testSubmitOrder() {
+ getDriver().get("https://play1.automationcamp.ir/");
+
+ JavascriptExecutor js = (JavascriptExecutor) getDriver();
+ js.executeScript("arguments[0].scrollIntoView();", getDriver().findElement(By.xpath("//h5[contains(text(), 'Sample Pages')]")));
+
+ getDriver().findElement(By.xpath("//h5[contains(text(), 'Sample Pages')]/parent::div/following-sibling::div//a")).click();
+
+ WebElement user = getDriver().findElement(By.xpath("//input[@id='user']"));
+ user.click();
+ user.clear();
+ user.sendKeys("admin");
+
+ WebElement password = getDriver().findElement(By.xpath("//input[@id='password']"));
+ password.click();
+ password.clear();
+ password.sendKeys("admin");
+
+ getDriver().findElement(By.xpath("//button[@id='login']")).click();
+
+ WebElement header = getDriver().findElement(By.xpath("//h3"));
+
+ Assert.assertEquals(header.getText(), "Dinesh's Pizza House");
+ }
+
+ @Test
+ public void testApplitoolsDemo() {
+
+ //pass on the target URL
+ getDriver().get("https://demo.applitools.com/");
+
+ //find username field and send over an input
+ WebElement userNameField = getDriver().findElement(By.id("username"));
+ userNameField.sendKeys("standard_user");
+
+ // find password field and send over an input
+ WebElement passwordField = getDriver().findElement(By.id("password"));
+ passwordField.sendKeys("12345qwera");
+
+ // find log-in button and do the click
+ getDriver().findElement(By.id("log-in")).click();
+
+ //find the static text visible after the user is logged in
+ WebElement h6FindText = getDriver().findElement(By.xpath(("(//h6[@class='element-header'])[1]")));
+ String h6String = h6FindText.getText();
+
+ //check if the "Financial Overview" text exists
+ Assert.assertEquals(h6String, "Financial Overview");
+ }
+
+ @Test
+ public void testItemSearch() throws InterruptedException {
+ getDriver().get("https://www.applebees.com/en");
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().manage().window().maximize();
+ Thread.sleep(1000);
+
+ WebElement menuButton = getDriver().findElement(By.xpath("(//ul/li/a[@href='/en/menu'])[1]"));
+ menuButton.click();
+
+ WebElement searchMenu = getDriver().findElement(By.xpath("//a[@href='/en/menu-search']"));
+ searchMenu.click();
+
+ WebElement textBox = getDriver().findElement(By.xpath("//input[contains(@class,'menu-search')]"));
+ textBox.sendKeys("salmon");
+
+ WebElement massage = getDriver().findElement(By.xpath("//a[@href='/en/menu/seafood/blackened-cajun-salmon']"));
+ String value = massage.getText();
+
+ Assert.assertEquals(value, "Blackened Cajun Salmon");
+ }
+
+ @Test
+ public void testLocationList() {
+ List expectedLocationsNames = List.of("Bensalem", "Doylestown", "Langhorne", "Levittown", "Perkasie", "Quakertown", "Yardley-Makefield");
+ List actualLocationNames = new ArrayList<>();
+
+ getDriver().get("https://buckslib.org/");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.xpath("//*[contains(text(),' Locations')]")).click();
+
+ for (String locationName : expectedLocationsNames) {
+ String locationText = getDriver()
+ .findElement(By.xpath("//div[@id='wp-faqp-accordion-1']/div/div[@class='faq-title']/h4[text()='" + locationName + "']")).getText();
+ actualLocationNames.add(locationText);
+ }
+
+ Assert.assertEquals(actualLocationNames, expectedLocationsNames);
+ }
+
+ @Test
+ public void linkTest() {
+ getDriver().get("https://the-internet.herokuapp.com/redirector");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.id("redirect")).click();
+ getDriver().findElement(By.xpath("//*[@id=\"content\"]/div/ul/li[3]/a")).click();
+ String textStatusCode = getDriver().findElement(By.xpath("//*[@id=\"content\"]/div/p")).getText();
+ boolean isStatus = textStatusCode.contains("404 status code");
+
+ Assert.assertTrue(isStatus);
+ }
+
+ @Test
+ public void datePicker() {
+ getDriver().get("https://www.selenium.dev/selenium/web/web-form.html");
+
+ WebElement myDate = getDriver().findElement(By.name("my-date"));
+ myDate.click();
+
+ WebElement weekDay = getDriver().findElement(By.xpath("//thead/tr[3]/th[1]"));
+ String text = weekDay.getText();
+
+ Assert.assertEquals(text,"Su");
+ }
+
+ @Test
+ public void testSwagLogin() {
+ getDriver().get("https://www.saucedemo.com/?ref=hackernoon.com");
+
+ WebElement usernameInput = getDriver().findElement(By.id("user-name"));
+ usernameInput.sendKeys("standard_user");
+
+ WebElement passwordInput = getDriver().findElement(By.id("password"));
+ passwordInput.sendKeys("secret_sauce");
+
+ WebElement loginButton = getDriver().findElement(By.id("login-button"));
+ loginButton.click();
+ WebElement shopCartButton = getDriver().findElement(By.id("shopping_cart_container"));
+
+ Assert.assertTrue(shopCartButton.isDisplayed(), "Shop cart doesn't displayed");
+ }
+
+ @Test
+ public void testPlaceAnOrder() {
+ getDriver().get("https://www.papajohns.com/");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.xpath("//*[@href=' /order/menu']")).click();
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(2000));
+
+ getDriver().findElement(By.cssSelector("[aria-label=\"Order Now Pepperoni Pizza\"]")).click();
+
+ WebElement text = getDriver().findElement(By.xpath("//h2[text()='Find Your Store']"));
+ String value = text.getText();
+ Assert.assertEquals(value,"FIND YOUR STORE");
+ }
+ @Test
+ public void testYMCA() {
+ getDriver().get("https://ymcacapecod.org/");
+
+ WebElement textBox = getDriver().findElement(By.className("field"));
+ WebElement searchButton = getDriver().findElement(By.className("submit"));
+ textBox.sendKeys("pool");
+ searchButton.click();
+
+ getDriver().findElement(By.xpath("//footer//a[@href='/programs/swimming/']")).click();
+
+ WebElement text = getDriver().findElement(By.xpath("//h1[@class='program-hero__title']"));
+ String value = text.getText();
+ Assert.assertEquals(value, "SWIM LESSONS");
+ }
+
+ @Test
+ public void testRegistration() {
+ getDriver().get("https://ymcacapecod.org/");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.xpath("//*[@href='/join/register/']")).click();
+ String originalWindow = getDriver().getWindowHandle();
+ Assert.assertEquals(getDriver().getWindowHandles().size(), 1);
+
+ getDriver().findElement(By.xpath("//*[@title='Register']")).click();
+ for (String windowHandle : getDriver().getWindowHandles()) {
+ if(!originalWindow.contentEquals(windowHandle)) {
+ getDriver().switchTo().window(windowHandle);
+ break;
+ }
+ }
+
+ getDriver().findElement(By.xpath("//a[contains(text(),'Login')]")).click();
+
+ WebElement username = getDriver().findElement(By.xpath("//input[@id='user_name']"));
+ username.sendKeys("1234@gmail.com");
+ getDriver().findElement(By.id("submit_button")).click();
+
+ String signup = getDriver().findElement(By.xpath("//h2")).getText();
+
+ Assert.assertEquals(signup,"Sign up for an account");
+ }
+
+ @Test
+ public void testMouseHover() {
+ getDriver().get("https://play1.automationcamp.ir/");
+
+ WebElement buttonMouseViewPage = getDriver().findElement(By.xpath("//a[starts-with(@*,'mouse')]"));
+ buttonMouseViewPage.click();
+
+ WebElement elementToHoverOver = getDriver().findElement(By.xpath("//button[@class='dropbtn']"));
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(elementToHoverOver).perform();
+
+ WebElement subMenuItem = getDriver().findElement(By.id("dd_python"));
+ subMenuItem.click();
+
+ WebElement text = getDriver().findElement(By.id("hover_validate"));
+ String value = text.getText();
+
+ Assert.assertEquals(value, "Python");
+ }
+
+ @Test
+ public void testDatalist() {
+
+ getDriver().get("https://www.selenium.dev/selenium/web/web-form.html");
+
+ WebElement dataList = getDriver().findElement(By.name("my-datalist"));
+ dataList.click();
+
+ WebElement options = getDriver().findElement(By.cssSelector("datalist#my-options option:nth-child(2)"));
+ String optionValue = options.getAttribute("value");
+ dataList.sendKeys(optionValue);
+
+ Assert.assertEquals(optionValue,"New York");
+
+ }
+
+ @Test
+ public void testPositiveLogin() throws InterruptedException {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().manage().window().maximize();
+ WebElement usernameField = getDriver().findElement(By.id("user-name"));
+ usernameField.sendKeys("standard_user");
+ WebElement passwordField = getDriver().findElement(By.id("password"));
+ passwordField.sendKeys("secret_sauce");
+
+ getDriver().findElement(By.id("login-button")).click();
+ String actualUrl="https://www.saucedemo.com/inventory.html";
+ String expectedUrl= getDriver().getCurrentUrl();
+ Assert.assertEquals(actualUrl, expectedUrl);
+ }
+
+ @Test
+ public void testSwag() {
+ getDriver().get("https://www.saucedemo.com/v1/");
+ getDriver().manage().window().maximize();
+
+ WebElement userNameField = getDriver().findElement(By.id("user-name"));
+ userNameField.sendKeys("locked_out_user");
+
+ WebElement passwordField = getDriver().findElement(By.id("password"));
+ passwordField.sendKeys("secret_sauce");
+
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement actualErrorMessage = getDriver().findElement(By.xpath("//h3[@data-test='error']"));
+
+ Assert.assertEquals(actualErrorMessage.getText(), "Epic sadface: Sorry, this user has been locked out.");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/GroupUnitedByJava8Test.java b/src/test/java/school/redrover/old/GroupUnitedByJava8Test.java
new file mode 100644
index 0000000..8101df8
--- /dev/null
+++ b/src/test/java/school/redrover/old/GroupUnitedByJava8Test.java
@@ -0,0 +1,520 @@
+package school.redrover.old;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+@Ignore
+public class GroupUnitedByJava8Test extends BaseTest {
+ private static final String GLOBALS_QA_LOGIN_LINKS = "https://www.globalsqa.com/angularJs-protractor/BankingProject/#/login";
+ private static final String GLOBALS_QA_STRING_VALUE = "testPV";
+ private static final String STANDARD_USER_LOGIN = "standard_user";
+ private static final String STANDARD_USER_PASSWORD = "secret_sauce";
+ private static final String EXPECTED_TEXT = "Sauce Labs Backpack";
+
+ @Test
+ public void testDemoQADoubleClick() {
+ getDriver().get("https://demoqa.com/");
+
+ WebElement elementsPage = getDriver().findElement(By.xpath("//h5[text()='Elements']"));
+ elementsPage.click();
+ WebElement buttons = getDriver().findElement(By.xpath("//span[@class='text' and text()='Buttons']"));
+ buttons.click();
+
+ WebElement doubleClickMeButton = getDriver().findElement(By.id("doubleClickBtn"));
+ new Actions(getDriver())
+ .doubleClick(doubleClickMeButton)
+ .perform();
+
+ String doubleClickMessageText = getDriver().findElement(By.id("doubleClickMessage")).getText();
+
+ Assert.assertEquals(doubleClickMessageText, "You have done a double click");
+ }
+
+ @Test
+ public void testLookingForTheSummer() {
+ WebDriverWait webDriverWait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
+
+ getDriver().get("https://www.onlinetrade.ru/");
+ webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name = 'query']"))).sendKeys("лето");
+ getDriver().findElement(By.xpath("//input[@type = 'submit']")).click();
+
+ Assert.assertTrue((getDriver().findElement(By.xpath("//h1[contains(text(), 'Найденные товары')]")).isDisplayed()));
+ }
+
+ @Test
+ public void testCreateNewUserGlobalQAAsManager() {
+ WebDriver driver = getDriver();
+ driver.get(GLOBALS_QA_LOGIN_LINKS);
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+
+ WebElement managerButton = driver.findElement(By.xpath("//button[@ng-click='manager()']"));
+ managerButton.click();
+
+ WebElement addCustomerButton = driver.findElement(By.xpath("//button[@ng-click='addCust()']"));
+ addCustomerButton.click();
+
+ WebElement boxFNText = driver.findElement(By.xpath("//input[@ng-model='fName']"));
+ boxFNText.sendKeys(GLOBALS_QA_STRING_VALUE);
+
+ WebElement boxLNText = driver.findElement(By.xpath("//input[@ng-model='lName']"));
+ boxLNText.sendKeys(GLOBALS_QA_STRING_VALUE);
+
+ WebElement boxPCText = driver.findElement(By.xpath("//input[@ng-model='postCd']"));
+ boxPCText.sendKeys(GLOBALS_QA_STRING_VALUE);
+
+ WebElement addCustomerSubmitButton = driver.findElement(By.xpath("//button[@type='submit']"));
+ addCustomerSubmitButton.click();
+
+ driver.switchTo().alert().accept();
+
+ WebElement goCustomersButton = driver.findElement(By.xpath("//button[@ng-click='showCust()']"));
+ goCustomersButton.click();
+
+ WebElement searchInput = driver.findElement(By.xpath("//input[@ng-model='searchCustomer']"));
+ searchInput.sendKeys(GLOBALS_QA_STRING_VALUE);
+
+ WebElement searchResultsTable = driver.findElement(By.xpath("//tbody/tr[last()]/td[1]"));
+ Assert.assertEquals(searchResultsTable.getText(), GLOBALS_QA_STRING_VALUE);
+ }
+
+ @Test
+ public void testHappyPathLogin() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ WebElement name = getDriver().findElement(By.xpath("//input[@id='user-name']"));
+ name.sendKeys("visual_user");
+
+ WebElement password = getDriver().findElement(By.xpath("//input[@id='password']"));
+ password.sendKeys("secret_sauce");
+
+ getDriver().findElement(By.id("login-button")).click();
+ String actualResult = getDriver().getCurrentUrl();
+
+ Assert.assertEquals(actualResult, "https://www.saucedemo.com/inventory.html");
+ }
+
+ @Test
+ public void testAlertAppearsAfterItemIsAddedToCart() {
+
+ getDriver().get("https://magento.softwaretestingboard.com/");
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(2));
+
+ WebElement searchField = getDriver().findElement(By.id("search"));
+ searchField.sendKeys("Pant");
+
+ WebElement submitButton = getDriver().findElement(By.xpath("//div[@class='actions']/button"));
+ submitButton.click();
+
+ WebElement submitShortLink = getDriver().findElement(By.xpath("//a[contains(., 'Cronus')]"));
+ submitShortLink.click();
+
+ WebElement submitSize = getDriver().findElement(By.xpath("//*[@id=\"option-label-size-143-item-175\"]"));
+ submitSize.click();
+
+ WebElement submitColor = getDriver().findElement(By.xpath("//div[@option-id ='49']"));
+ submitColor.click();
+
+ WebElement submitQty = getDriver().findElement(By.id("qty"));
+ submitQty.sendKeys("12");
+
+ WebElement submitAddToCart = getDriver().findElement(By.id("product-addtocart-button"));
+ submitAddToCart.click();
+
+ WebElement alertShoppingCart = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@role='alert']")));
+
+ Assert.assertTrue(alertShoppingCart.isDisplayed());
+ Assert.assertEquals(alertShoppingCart.getText(), "You added Cronus Yoga Pant to your shopping cart.");
+ }
+
+ @Test
+ public void testCheckingAddingCart() {
+ WebDriver driver = getDriver();
+
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement userName = driver.findElement(By.id("user-name"));
+ userName.sendKeys(STANDARD_USER_LOGIN);
+ WebElement userPassword = driver.findElement(By.id("password"));
+ userPassword.sendKeys(STANDARD_USER_PASSWORD);
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+
+ WebElement addCartButton = driver.findElement(By.name("add-to-cart-sauce-labs-backpack"));
+ addCartButton.click();
+ WebElement shoppingCart = driver.findElement(By.className("shopping_cart_link"));
+ shoppingCart.click();
+
+ WebElement cartList = driver.findElement(By.id("item_4_title_link"));
+
+ Assert.assertEquals(cartList.getText(), EXPECTED_TEXT);
+ }
+
+ @Test
+ public void testAddingItemToCart() {
+
+ WebDriver driver = getDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+
+ WebElement pass = driver.findElement(By.id("password"));
+ pass.sendKeys("secret_sauce");
+
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+
+ WebElement addButton = driver.findElement(By.id("add-to-cart-sauce-labs-bike-light"));
+ addButton.click();
+
+ WebElement shoppingCart = driver.findElement(By.id("shopping_cart_container"));
+ shoppingCart.click();
+
+ WebElement labsBikeText = driver.findElement(By.id("item_0_title_link"));
+ String resultText = labsBikeText.getText();
+
+ Assert.assertEquals(resultText, "Sauce Labs Bike Light");
+ }
+
+ @Test
+ public void testLogoutUser() throws InterruptedException {
+
+ WebDriver driver = getDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("visual_user");
+
+ WebElement pass = driver.findElement(By.id("password"));
+ pass.sendKeys("secret_sauce");
+
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+
+ WebElement burgerButton = driver.findElement(By.id("react-burger-menu-btn"));
+ burgerButton.click();
+
+ Thread.sleep(1000);
+
+ WebElement logoutButton = driver.findElement(By.id("logout_sidebar_link"));
+ logoutButton.click();
+
+ String textTitle = driver.getTitle();
+ Assert.assertEquals(textTitle, "Swag Labs");
+ }
+
+ @Test
+ public void testDemoQARightClick() {
+ getDriver().get("https://demoqa.com/");
+
+ WebElement elementsPage = getDriver().findElement(By.xpath("//h5[text()='Elements']"));
+ elementsPage.click();
+ WebElement buttons = getDriver().findElement(By.xpath("//span[@class='text' and text()='Buttons']"));
+ buttons.click();
+
+ WebElement rightClickMeButton = getDriver().findElement(By.id("rightClickBtn"));
+ new Actions(getDriver())
+ .contextClick(rightClickMeButton)
+ .perform();
+
+ String contextClickMessageText = getDriver().findElement(By.id("rightClickMessage")).getText();
+
+ Assert.assertEquals(contextClickMessageText, "You have done a right click");
+ }
+
+ @Test
+ public void testPraktikum() throws InterruptedException {
+ getDriver().get("https://qa-mesto.praktikum-services.ru/signin");
+
+ WebElement eMail = getDriver().findElement(By.id("email"));
+ eMail.sendKeys("wovibic859@mnsaf.com");
+
+ WebElement password = getDriver().findElement(By.id("password"));
+ password.sendKeys("123");
+
+ WebElement LoginEnter = getDriver().findElement(By.className("auth-form__button"));
+ LoginEnter.click();
+
+ Thread.sleep(3000);
+ WebElement accountName = getDriver().findElement(By.className("profile__title"));
+ Assert.assertEquals(accountName.getText(), "Жак-Ив Кусто");
+ }
+
+ @Test
+ public void testSuccessLoginSaucedemo() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.id("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.id("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+
+ Assert.assertEquals(getDriver().findElement(By.xpath("//div[@class='app_logo']")).getText(), "Swag Labs");
+ }
+
+ @Test
+ public void testClassifiedCheckbox() {
+ getDriver().get("https://demoqa.com");
+
+ getDriver().findElement(By.xpath("//h5[text()='Elements']")).click();
+ getDriver().findElement(By.id("item-1")).click();
+ getDriver().findElement(By.className("rct-option-expand-all")).click();
+ getDriver().findElement(By.xpath("//label[@for='tree-node-classified']")).click();
+ String value = getDriver().findElement(By.id("result")).getText();
+
+ Assert.assertEquals(value, "You have selected :\n" + "classified");
+ }
+
+ @Test
+ public void testItemsSortedInReverseOrder() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys(STANDARD_USER_LOGIN);
+ getDriver().findElement(By.id("password")).sendKeys(STANDARD_USER_PASSWORD);
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement itemsSortingCriterion = getDriver().findElement(By.className("product_sort_container"));
+ Select select = new Select(itemsSortingCriterion);
+ select.selectByVisibleText("Name (Z to A)");
+
+ List items = getDriver().findElements(By.xpath("//div[@class='inventory_item_name ']"));
+
+ List itemsNames = new ArrayList<>();
+ for (WebElement itemName : items) {
+ String name = itemName.getText();
+ itemsNames.add(name);
+ }
+
+ List expectedSortedNames = new ArrayList<>(itemsNames);
+ expectedSortedNames.sort(Collections.reverseOrder());
+
+ Assert.assertEquals(itemsNames, expectedSortedNames);
+ }
+
+ @Test
+ public void testLoginAsCustomerHarryPotterGlobalsqa() throws InterruptedException {
+ getDriver().get("https://www.globalsqa.com/angularJs-protractor/BankingProject/#/login");
+
+ Thread.sleep(1500);
+
+ WebElement customerLoginButton = getDriver().findElement(By.xpath("//button[@ng-click='customer()']"));
+ customerLoginButton.click();
+
+ Thread.sleep(1500);
+
+ Select select = new Select(getDriver().findElement(By.id("userSelect")));
+ select.selectByIndex(2);
+
+ WebElement loginButton = getDriver().findElement(By.xpath("//button[@type = 'submit']"));
+ loginButton.click();
+
+ Thread.sleep(1500);
+
+ WebElement welcomeText = getDriver().findElement(By.xpath("//strong[text() = ' Welcome ']"));
+
+ Assert.assertEquals(welcomeText.getText(), "Welcome Harry Potter !!");
+ }
+
+ @Test
+ public void testCartAddItemBikeLight() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys(STANDARD_USER_LOGIN);
+ getDriver().findElement(By.id("password")).sendKeys(STANDARD_USER_PASSWORD);
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement addBikeLightToCartButton = getDriver().findElement(By.id("add-to-cart-sauce-labs-bike-light"));
+ addBikeLightToCartButton.click();
+
+ WebElement cartClickIcon = getDriver().findElement(By.className("shopping_cart_link"));
+ cartClickIcon.click();
+
+ WebElement itemInCart = getDriver().findElement(By.id("item_0_title_link"));
+ itemInCart.getText();
+
+ Assert.assertEquals(itemInCart.getText(), "Sauce Labs Bike Light", "Wrong item in the Cart");
+ }
+
+ @Test
+ public void testItemsSortedAlphabetically() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys(STANDARD_USER_LOGIN);
+ getDriver().findElement(By.id("password")).sendKeys(STANDARD_USER_PASSWORD);
+ getDriver().findElement(By.id("login-button")).click();
+
+ List items = getDriver().findElements(By.cssSelector("[class^='inventory_item_name']"));
+
+ List itemsNames = new ArrayList<>();
+ for (WebElement itemName : items) {
+ String name = itemName.getText();
+ itemsNames.add(name);
+ }
+
+ List expectedSortedNames = new ArrayList<>(itemsNames);
+ Collections.sort(expectedSortedNames);
+
+ Assert.assertEquals(itemsNames, expectedSortedNames, "Items are not sorted alphabetically");
+ }
+
+ @Test
+ public void testDefaultSortingCriterion() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys(STANDARD_USER_LOGIN);
+ getDriver().findElement(By.id("password")).sendKeys(STANDARD_USER_PASSWORD);
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement itemsSortingCriterion = getDriver().findElement(By.className("product_sort_container"));
+ String defaultSortingCriterion = new Select(itemsSortingCriterion).getFirstSelectedOption().getText();
+
+ Assert.assertEquals(defaultSortingCriterion, "Name (A to Z)",
+ "Default sorting criterion is not alphabetical");
+ }
+ @Test
+ public void testAlertAppearsAfterRatingIsNotSelected() {
+ getDriver().get("https://magento.softwaretestingboard.com");
+ getDriver().findElement(By
+ .xpath("//span[contains (.,'Women')]")).click();
+ getDriver().findElement(By
+ .xpath("//div[contains(@class, 'categories')]//a[contains(., 'Hoodies')]")).click();
+ getDriver().findElement(By
+ .xpath("//a[contains(., 'Circe')]")).click();
+ getDriver().findElement(By
+ .xpath("//a[normalize-space(.) = 'Reviews']")).click();
+ getDriver().findElement(By.id("nickname_field")).sendKeys("Chubaka");
+ getDriver().findElement(By.id("summary_field")).sendKeys("My f***king sh**ty review");
+ getDriver().findElement(By.id("review_field")).sendKeys("bla bla bla");
+ getDriver().findElement(By
+ .xpath("//button[normalize-space(.) = 'Submit Review']")).click();
+ WebElement alert = getDriver().findElement(By.id("ratings[4]-error"));
+
+ Assert.assertTrue(alert.isDisplayed());
+ Assert.assertEquals(alert.getText(), "Please select one of each of the ratings above.");
+ }
+ @Test
+ public void testLoginInvalidUser() {
+
+ getDriver().manage().window().maximize();
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys("user");
+ getDriver().findElement(By.id("password")).sendKeys("user");
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement errorText = getDriver().findElement(By.xpath("//h3[@data-test= 'error']"));
+ Assert.assertEquals(errorText.getText(), "Epic sadface: Username and password do not match any user in this service");
+ }
+
+ @Test
+ public void testRemoveItemFromCart() {
+
+ getDriver().manage().window().maximize();
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("user-name")).sendKeys(STANDARD_USER_LOGIN);
+ getDriver().findElement(By.id("password")).sendKeys(STANDARD_USER_PASSWORD);
+ getDriver().findElement(By.id("login-button")).click();
+
+ WebElement addingButton = getDriver().findElement(By.id("add-to-cart-sauce-labs-backpack"));
+ addingButton.click();
+ WebElement cartIcon = getDriver().findElement(By.id("shopping_cart_container"));
+ cartIcon.click();
+ WebElement removeButton = getDriver().findElement(By.id("remove-sauce-labs-backpack"));
+ removeButton.click();
+
+ Assert.assertTrue(getDriver().findElements(By.id("item_4_title_link")).isEmpty());
+
+ }
+
+ @Test
+ public void testSaucedemoPlaceholderUsernameByDefault() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ Assert.assertEquals(getDriver().findElement(By.name("user-name")).getAttribute("placeholder"), "Username");
+ }
+
+ @Test
+ public void testSaucedemoPasswordPlaceholderByDefault() {
+ getDriver().get("https://www.saucedemo.com/");
+
+ Assert.assertEquals(getDriver().findElement(By.name("password")).getAttribute("placeholder"), "Password");
+ }
+
+ @Test
+ public void testSaucedemoErrorLoginWithEmptyInputs() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("login-button")).click();
+ WebElement emptyLoginError = getDriver().findElement(By.xpath("//div/h3[@data-test='error']"));
+ WebElement errorUsernameCrossSVG =getDriver().findElement(By.cssSelector("#user-name + .svg-inline--fa"));
+ WebElement errorPasswordCrossSVG =getDriver().findElement(By.cssSelector("#password + .svg-inline--fa"));
+
+ Assert.assertTrue(emptyLoginError.isDisplayed());
+ Assert.assertEquals(emptyLoginError.getText(), "Epic sadface: Username is required");
+ Assert.assertTrue(errorUsernameCrossSVG.isDisplayed());
+ Assert.assertTrue(errorPasswordCrossSVG.isDisplayed());
+ }
+
+ @Test
+ public void testSaucedemoErrorLoginCloseErrorMessage() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.id("login-button")).click();
+ WebElement userLoginError = getDriver().findElement(By.xpath("//div/h3[@data-test='error']"));
+ userLoginError.isDisplayed();
+ getDriver().findElement(By.className("error-button")).click();
+ boolean result = getDriver().findElements(By.xpath("//div/h3[@data-test='error']")).isEmpty();
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testSaucedemoIncorrectDataLogin() {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().findElement(By.name("user-name")).sendKeys("user");
+ getDriver().findElement(By.name("password")).sendKeys("user");
+ getDriver().findElement(By.id("login-button")).click();
+ WebElement userLoginError = getDriver().findElement(
+ By.xpath("//div/h3[@data-test='error']"));
+
+ Assert.assertTrue(userLoginError.isDisplayed());
+ Assert.assertEquals(userLoginError.getText(),
+ "Epic sadface: Username and password do not match any user in this service");
+ }
+ @Test
+ public void testCart() throws InterruptedException {
+ getDriver().get("https://magento.softwaretestingboard.com/");
+ getDriver().manage().window().maximize();
+
+ WebElement salePageButton = getDriver().findElement(By.id("ui-id-8"));
+ salePageButton.click();
+ WebElement shopWomanDealButton = getDriver().findElement(By.xpath("//span[@class = 'more button']"));
+ shopWomanDealButton.click();
+ WebElement bessYogaShortItemLink = getDriver().
+ findElement(By.xpath("//a[contains(., 'Bess')]"));
+ bessYogaShortItemLink.click();
+ WebElement sizeSelect = getDriver().findElement(By.xpath("//div[@option-id='171']"));
+ sizeSelect.click();
+ Thread.sleep(1000);
+ WebElement colorSelect = getDriver().findElement(By.xpath("//div[@option-id='50']"));
+ colorSelect.click();
+ WebElement addToCard = getDriver().findElement(By.id("product-addtocart-button"));
+ addToCard.click();
+ Thread.sleep(3000);
+ WebElement cartCounterNumber = getDriver().findElement(By.xpath("//span[@class ='counter-number']"));
+ cartCounterNumber.click();
+
+ Thread.sleep(3000);
+ Assert.assertEquals((getDriver().findElement(By
+ .xpath("//strong[@class='product-item-name']/a")).getText()),
+ "Bess Yoga Short");
+ }
+}
diff --git a/src/test/java/school/redrover/old/GuruTest.java b/src/test/java/school/redrover/old/GuruTest.java
new file mode 100644
index 0000000..ed4e522
--- /dev/null
+++ b/src/test/java/school/redrover/old/GuruTest.java
@@ -0,0 +1,47 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class GuruTest {
+ @Test
+ public void FormTest() {
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demo.guru99.com/test/login.html");
+
+ WebElement email = driver.findElement(By.id("email"));
+ email.sendKeys("abcd@gmail.com");
+
+ WebElement password = driver.findElement(By.name("passwd"));
+ password.sendKeys("abcdefghlkjl");
+
+ WebElement login = driver.findElement(By.id("SubmitLogin"));
+ login.click();
+
+ driver.quit();
+ }
+
+ @Test
+ public void GuruRadioTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demo.guru99.com/test/radio.html");
+
+ WebElement radio1 = driver.findElement(By.id("vfb-7-1"));
+ radio1.click();
+
+ WebElement radio2 = driver.findElement(By.id("vfb-7-2"));
+ radio2.click();
+
+ WebElement option1 = driver.findElement(By.id("vfb-6-0"));
+ option1.click();
+
+ driver.quit();
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/HW17StanKTest.java b/src/test/java/school/redrover/old/HW17StanKTest.java
new file mode 100644
index 0000000..5da8c74
--- /dev/null
+++ b/src/test/java/school/redrover/old/HW17StanKTest.java
@@ -0,0 +1,35 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class HW17StanKTest {
+ @Test
+ public void newTest(){
+ WebDriver driver = new ChromeDriver();
+
+ driver.get("https://www.saucedemo.com");
+
+ WebElement fieldLogin = driver.findElement(By.name("user-name"));
+ fieldLogin.sendKeys("standard_user");
+
+ WebElement fieldPassword = driver.findElement(By.name("password"));
+ fieldPassword.sendKeys("secret_sauce");
+
+ WebElement button = driver.findElement(By.id("login-button"));
+ button.sendKeys(Keys.ENTER);
+
+ WebElement message = driver.findElement(By.className("app_logo"));
+ String value = message.getText();
+
+ Assert.assertEquals(value, "Swag Labs");
+
+ driver.quit();
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/HerokuappTest.java b/src/test/java/school/redrover/old/HerokuappTest.java
new file mode 100644
index 0000000..9e5a1ec
--- /dev/null
+++ b/src/test/java/school/redrover/old/HerokuappTest.java
@@ -0,0 +1,32 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class HerokuappTest {
+ @Test
+ public void testPage() throws InterruptedException{
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://the-internet.herokuapp.com");
+
+ WebElement link = driver.findElement(By.linkText("JavaScript Alerts"));
+ link.click();
+
+ Thread.sleep(500);
+
+ WebElement jsalert = driver.findElement(By.xpath("//button[.='Click for JS Alert']"));
+ jsalert.click();
+ driver.switchTo().alert().accept();
+
+ String result = driver.findElement(By.id("result")).getText();
+ Assert.assertEquals(result,"You successfully clicked an alert");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/JavAngryTest.java b/src/test/java/school/redrover/old/JavAngryTest.java
new file mode 100644
index 0000000..9b48b11
--- /dev/null
+++ b/src/test/java/school/redrover/old/JavAngryTest.java
@@ -0,0 +1,254 @@
+package school.redrover.old;
+
+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.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Ignore
+public class JavAngryTest extends BaseTest {
+
+ @Test
+ void testPriceCheckMainPageShoppingPage() {
+ WebDriver webDriver = new ChromeDriver();
+ final String login = "standard_user";
+ final String password = "secret_sauce";
+ final String itemToBuy = "Sauce Labs Bike Light".toLowerCase().replaceAll(" ", "-");
+ webDriver.get("https://www.saucedemo.com/");
+ webDriver.findElement(By.id("user-name")).sendKeys(login);
+ webDriver.findElement(By.id("password")).sendKeys(password);
+ webDriver.findElement(By.id("login-button")).click();
+ String expectedResult = webDriver.findElement(
+ By.xpath("//button[contains(@name, '" + itemToBuy + "')]/../div")).getText();
+ webDriver.findElement(By.xpath("//button[@id='add-to-cart-" + itemToBuy + "']")).click();
+ webDriver.findElement(By.className("shopping_cart_link")).click();
+ String actualResult = webDriver.findElement(
+ By.xpath("//button[contains(@name, '" + itemToBuy + "')]/../div")).getText();
+
+ Assert.assertEquals(actualResult, expectedResult);
+ webDriver.quit();
+ }
+
+ @Test
+ void testDoubleClickButton() {
+ getDriver().get("https://demoqa.com/");
+
+ String expectedText = "You have done a double click";
+
+ getDriver().findElement(By.xpath("//h5[text()='Elements']")).click();
+ getDriver().findElement(By.xpath("//span[text() = 'Buttons']")).click();
+ WebElement clickable = getDriver().findElement(By.id("doubleClickBtn"));
+ new Actions(getDriver())
+ .doubleClick(clickable)
+ .perform();
+
+ String actualText = getDriver().findElement(By.id("doubleClickMessage")).getText();
+
+ Assert.assertEquals(actualText, expectedText);
+ }
+
+ @Test
+ void testActionCardsTitlesDemoQAMainPage() {
+ getDriver().get("https://demoqa.com/");
+
+ List expectedBannerTitles = new ArrayList<>(Arrays.asList("Elements", "Forms", "Alerts, Frame & Windows",
+ "Widgets", "Interactions", "Book Store Application"));
+ List elementList = getDriver().findElements(By.xpath("//div[@class='card mt-4 top-card']"));
+ List actualBannerTitles = WebElementToString(elementList);
+
+ Assert.assertEquals(actualBannerTitles, expectedBannerTitles);
+ }
+
+ public static List WebElementToString(List elementList) {
+ List stringList = new ArrayList<>();
+ for (WebElement element : elementList) {
+ stringList.add(element.getText());
+ }
+
+ return stringList;
+ }
+
+ @Test
+ public void testCheckBox1() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/checkbox");
+ WebElement checkBox = driver.findElement(By.className("rct-checkbox"));
+ checkBox.click();
+ WebElement resultText = driver.findElement(By.id("result"));
+ resultText.getText();
+
+ Assert.assertEquals(resultText.getText(), "You have selected :\n" +
+ "home\n" +
+ "desktop\n" +
+ "notes\n" +
+ "commands\n" +
+ "documents\n" +
+ "workspace\n" +
+ "react\n" +
+ "angular\n" +
+ "veu\n" +
+ "office\n" +
+ "public\n" +
+ "private\n" +
+ "classified\n" +
+ "general\n" +
+ "downloads\n" +
+ "wordFile\n" +
+ "excelFile");
+ driver.quit();
+
+ }
+
+ @Test
+ public void testBuyBlueJeans() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+ driver.manage().window().maximize();
+ driver.get("https://askomdch.com/");
+ driver.findElement(By.xpath("//a[@href='/store'][text()='Shop Now']")).click();
+ driver.findElement(By.xpath("//a[contains(@aria-label,'Basic Blue Jeans')]")).click();
+ driver.findElement(By.xpath("//a[@class='added_to_cart wc-forward']")).click();
+ String pageName = driver.findElement(By.xpath("//h1")).getText();
+ Assert.assertEquals(pageName, "Cart");
+
+ }
+
+ @Test
+ public void testInputAndPagination() {
+ getDriver().get("https://portal.311.nyc.gov/");
+ getDriver().findElement(By.xpath("//input[@aria-label='Search']")).sendKeys("concerts");
+ getDriver().findElement(By.className("search-magnify")).click();
+
+ WebElement widgets = getDriver().findElement(By.xpath("//ul[@class='pagination']"));
+ int deltaY = widgets.getRect().y;
+ new Actions(getDriver())
+ .scrollByAmount(0, deltaY)
+ .perform();
+ getDriver().findElement(By.xpath("//ul[@class='pagination']"));
+ getDriver().findElement(By.linkText("2")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://portal.311.nyc.gov/search/?q=concerts&page=2");
+ }
+
+ @Test
+ public void testBuyBracelet() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));
+ driver.manage().window().maximize();
+ driver.get("https://askomdch.com/");
+
+ driver.findElement(By.xpath("//a[contains(text(), 'Check Out')]")).click();
+ driver.findElement(By.xpath("//a[contains(@aria-label,'Bangle Bracelet')]")).click();
+ driver.findElement(By.xpath("//a[@class='added_to_cart wc-forward']")).click();
+ String subtotal = driver.findElement(By.xpath("//td[@class='product-subtotal']")).getText();
+
+ Assert.assertEquals(subtotal, "$25.00");
+ driver.quit();
+ }
+
+ @Test
+ public void testCheckoutForm() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
+ driver.manage().window().maximize();
+ driver.get("https://askomdch.com/");
+
+ driver.findElement(By.xpath("//a[@class='wp-block-button__link']")).click();
+ driver.findElement(By.xpath("//a[contains(@data-product_id,'1193') and text()='Add to cart']")).click();
+ driver.findElement(By.xpath("(//a[@href='https://askomdch.com/cart/' and text()='View cart'])[3]")).click();
+ driver.findElement(By.xpath("//a[@class='checkout-button button alt wc-forward']")).click();
+ driver.findElement(By.xpath("//input[@id='billing_first_name']")).sendKeys("Ivan");
+ driver.findElement(By.xpath("//input[@id='billing_last_name']")).sendKeys("Ivanov");
+ driver.findElement(By.xpath("(//span[@class='select2-selection select2-selection--single'])[1]")).click();
+ // driver.findElement(By.xpath("(//span[@class='select2-selection__rendered' and @title='Belarus'])[1]")).click();
+ driver.findElement(By.xpath("(//span[@class='select2-selection__rendered' and @title='United States (US)'])[1]")).click();
+ driver.findElement(By.xpath("//input[@id='billing_address_1']")).sendKeys("125, Lenina street");
+ driver.findElement(By.xpath("//input[@id='billing_city']")).sendKeys("Sacramento");
+ driver.findElement(By.xpath("//span[@id='select2-billing_state-container']")).click();
+ driver.findElement(By.xpath("//input[@name='billing_postcode']")).click();
+ driver.findElement(By.xpath("//input[@name='billing_postcode']")).sendKeys("94203");
+ driver.findElement(By.xpath("//input[@name='billing_email']")).click();
+ driver.findElement(By.xpath("//input[@name='billing_email']")).sendKeys("Ivanov@mail.ru");
+ driver.findElement(By.xpath("//input[@id='createaccount']")).click();
+ driver.findElement(By.xpath("//input[@name='account_username']")).sendKeys("ivanov12");
+ driver.findElement(By.xpath("//input[@name='account_password']")).sendKeys("password");
+ driver.findElement(By.xpath("//input[@id='payment_method_cod']")).click();
+ driver.findElement(By.xpath("//button[@name='woocommerce_checkout_place_order']")).click();
+ driver.quit();
+ }
+
+ @Test
+ void testFields() {
+ WebDriver webDriver = getDriver();
+ webDriver.get("https://letcode.in/test");
+
+ webDriver.findElement(By.xpath("//a[contains(text(),'Edit')]")).click();
+ webDriver.findElement(By.id("fullName")).sendKeys("Ali Ian");
+ webDriver.findElement(By.id("join")).sendKeys(" and happy \t");
+ webDriver.findElement(By.id("clearMe")).clear();
+
+ Assert.assertTrue(webDriver.findElement(By.id("noEdit")).isDisplayed());
+ }
+
+ @Test
+ public void registrationTest() {
+ WebDriver driver = getDriver();
+ driver.get("https://demoqa.com/webtables");
+ driver.manage().window().maximize();
+
+ WebElement addBtn = driver.findElement(By.cssSelector("#addNewRecordButton"));
+ addBtn.click();
+
+ WebElement firstName = driver.findElement(By.id("firstName"));
+ firstName.sendKeys("Irina");
+
+ WebElement lastName = driver.findElement(By.id("lastName"));
+ lastName.sendKeys("Romanova");
+
+ WebElement email = driver.findElement(By.id("userEmail"));
+ email.sendKeys("test@test.ru");
+
+ WebElement age = driver.findElement(By.id("age"));
+ age.sendKeys("18");
+
+ WebElement salary = driver.findElement(By.id("salary"));
+ salary.sendKeys("180");
+
+ WebElement department = driver.findElement(By.id("department"));
+ department.sendKeys("IT");
+
+ WebElement btnSubmit = driver.findElement(By.id("submit"));
+ btnSubmit.click();
+
+ WebElement currentName = driver.findElement(By.xpath("//div[contains(text(),'Irina')]"));
+ String curName = currentName.getText();
+ Assert.assertEquals(curName, "Irina");
+ }
+
+ @Test
+ public void testDatika() {
+ getDriver().get("https://datika.me/ru/");
+
+ WebElement textBox = getDriver().findElement(By.id("search"));
+ textBox.sendKeys("Акция");
+
+ WebElement submitButton = getDriver().findElement(By.xpath("//*[@id='header']/div/div[2]/form/button"));
+ submitButton.click();
+
+ WebElement message = getDriver().findElement(By.xpath("//*[@id='page-content']/h1"));
+ String value = message.getText();
+
+ Assert.assertEquals(value, "По запросу «Акция»");
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/JavaHashGroupTest.java b/src/test/java/school/redrover/old/JavaHashGroupTest.java
new file mode 100644
index 0000000..ffea74c
--- /dev/null
+++ b/src/test/java/school/redrover/old/JavaHashGroupTest.java
@@ -0,0 +1,112 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+@Ignore
+public class JavaHashGroupTest extends BaseTest {
+
+ @Test
+ public void testMainPageTitle() {
+
+ final String expectedTitle = "Swag Labs";
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().get("https://www.saucedemo.com");
+
+ WebElement loginField = getDriver().findElement(By.xpath("//input[@id='user-name']"));
+ WebElement passField = getDriver().findElement(By.xpath("//input[@id='password']"));
+ WebElement submitButton = getDriver().findElement(By.xpath("//input[@id='login-button']"));
+
+ loginField.sendKeys("standard_user");
+ passField.sendKeys("secret_sauce");
+ submitButton.click();
+
+ String actualTitle = getDriver().findElement(By.xpath("//div[contains(text(),'Swag Labs')]")).getText();
+
+ Assert.assertEquals(actualTitle,expectedTitle);
+ }
+
+ @Test
+ public void testBuyingBlackShirt() {
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ getDriver().get("https://www.saucedemo.com");
+
+ WebElement loginField = getDriver().findElement(By.xpath("//input[@id='user-name']"));
+ WebElement passField = getDriver().findElement(By.xpath("//input[@id='password']"));
+ WebElement submitButton = getDriver().findElement(By.xpath("//input[@id='login-button']"));
+
+ loginField.sendKeys("standard_user");
+ passField.sendKeys("secret_sauce");
+ submitButton.click();
+
+ WebElement tshirtTitle = getDriver().findElement(By.xpath("//div[@class='inventory_item_name '][contains(text(),'Sauce Labs Bolt T-Shirt')]"));
+ tshirtTitle.click();
+
+ WebElement tshirtPageTitle = getDriver().findElement(By.xpath("//div[@class='inventory_details_name large_size'][contains(text(),'Sauce Labs Bolt T-Shirt')]"));
+ Assert.assertTrue(tshirtPageTitle.isDisplayed());
+
+ WebElement addToCartButton = getDriver().findElement(By.xpath("//button[contains(text(),'Add to cart')]"));
+ addToCartButton.click();
+
+ WebElement goToCartButton = getDriver().findElement(By.xpath("//a[@class='shopping_cart_link']"));
+ goToCartButton.click();
+
+ WebElement descriptionOfItemInCart = getDriver().findElement(By.xpath("//div[@class='inventory_item_desc']"));
+ Assert.assertTrue(descriptionOfItemInCart.isDisplayed());
+
+ WebElement checkoutButton = getDriver().findElement(By.xpath("//button[@id='checkout']"));
+ checkoutButton.click();
+
+ WebElement firstNameField = getDriver().findElement(By.xpath("//input[@placeholder='First Name']"));
+ WebElement lastNameField = getDriver().findElement(By.xpath("//input[@placeholder='Last Name']"));
+ WebElement postCodeField = getDriver().findElement(By.xpath("//input[@placeholder='Zip/Postal Code']"));
+
+ firstNameField.sendKeys("David");
+ lastNameField.sendKeys("Adams");
+ postCodeField.sendKeys("777777");
+
+ WebElement continueButton = getDriver().findElement(By.xpath("//input[@id='continue']"));
+ continueButton.click();
+
+ WebElement checkoutPageTitle = getDriver().findElement(By.xpath("//span[contains(text(),'Checkout: Overview')]"));
+ Assert.assertTrue(checkoutPageTitle.isDisplayed());
+
+ WebElement finishButton = getDriver().findElement(By.xpath("//button[@id='finish']"));
+ finishButton.click();
+
+ WebElement successOrderSign = getDriver().findElement(By.xpath("//h2[contains(text(),'Thank you for your order!')]"));
+ Assert.assertTrue(successOrderSign.isDisplayed());
+ }
+
+ private static final String BAD_USERNAME = "username@gmail.com";
+ private static final String BAD_PASSWORD = "Password123";
+ @Test
+ public void testBadLogin() throws InterruptedException {
+ getDriver().get("https://www.sofa.com/gb");
+
+ WebElement loginButton = getDriver().findElement(By.xpath("//a[@href=\"/gb/login\"]"));
+ loginButton.click();
+ Thread.sleep(500);
+
+ WebElement inputEmail = getDriver().findElement(By.id("j_username"));
+ inputEmail.sendKeys(BAD_USERNAME);
+ WebElement inputPassword = getDriver().findElement(By.id("j_password"));
+ inputPassword.sendKeys(BAD_PASSWORD);
+ getDriver().findElement(By.id("loginBtn")).click();
+ Thread.sleep(600);
+
+ WebElement errorText = getDriver().findElement(By.xpath("//div[@class=\"alert alert-danger alert-dismissable\"]"));
+
+ Assert.assertEquals(errorText.getText(), "×\n" + "Your username or password was incorrect.");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/JilfondTest.java b/src/test/java/school/redrover/old/JilfondTest.java
new file mode 100644
index 0000000..0afb172
--- /dev/null
+++ b/src/test/java/school/redrover/old/JilfondTest.java
@@ -0,0 +1,25 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class JilfondTest {
+
+ @Test
+ public void testTest() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://jilfond.ru/");
+
+ WebElement text = driver.findElement(By.name("price[to]"));
+ text.sendKeys("5000");
+
+ WebElement button = driver.findElement(By.id("js-search-map"));
+ button.click();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/KIATest.java b/src/test/java/school/redrover/old/KIATest.java
new file mode 100644
index 0000000..34bd8a6
--- /dev/null
+++ b/src/test/java/school/redrover/old/KIATest.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class KIATest {
+
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.kia-club.com.ua//ucp.php?mode=login");
+ WebElement username = driver.findElement(By.id("username"));
+ username.sendKeys("standard_user");
+
+ WebElement password = driver.findElement(By.id("password"));
+ password.sendKeys("Superuser2");
+
+ WebElement submitButton = driver.findElement(By.xpath("//*[@id=\"login\"]/div[1]/div/div/fieldset/dl[4]/dd/input[3]"));
+
+ submitButton.click();
+
+ String pageTitle = driver.getTitle();
+ Assert.assertEquals(pageTitle, "kia-club.com.ua. | Личный раздел •");
+
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/KIATest2.java b/src/test/java/school/redrover/old/KIATest2.java
new file mode 100644
index 0000000..0f3b005
--- /dev/null
+++ b/src/test/java/school/redrover/old/KIATest2.java
@@ -0,0 +1,33 @@
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class KIATest2 {
+
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.kia-club.com.ua//ucp.php?mode=login");
+ WebElement username = driver.findElement(By.id("username"));
+ username.sendKeys("standard_user");
+
+ WebElement password = driver.findElement(By.id("password"));
+ password.sendKeys("Superuser2");
+
+ WebElement submitButton = driver.findElement(By.xpath("//*[@id=\"login\"]/div[1]/div/div/fieldset/dl[4]/dd/input[3]"));
+
+ submitButton.click();
+
+ String pageTitle = driver.getTitle();
+ Assert.assertEquals(pageTitle, "kia-club.com.ua. | Личный раздел •");
+
+ driver.quit();
+ driver.quit();
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/LastChanceTest.java b/src/test/java/school/redrover/old/LastChanceTest.java
new file mode 100644
index 0000000..41edfd2
--- /dev/null
+++ b/src/test/java/school/redrover/old/LastChanceTest.java
@@ -0,0 +1,44 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class LastChanceTest {
+
+ @Test
+
+ public void testCurrencyCalculator(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://futureboy.us/fsp/dollar.fsp");
+
+ WebElement dollarQuantity = driver.findElement(By.xpath("//input[@name='quantity']"));
+ dollarQuantity.click();
+ dollarQuantity.sendKeys("100");
+
+ WebElement currency = driver.findElement(By.xpath("//select[@name ='currency']"));
+ currency.click();
+
+ WebElement selectCurrency = driver.findElement(By.xpath("//option[contains(text(),'mark')]"));
+ selectCurrency.click();
+
+ WebElement selectYear = driver.findElement(By.name("fromYear"));
+ selectYear.click();
+ selectYear.sendKeys("1900");
+
+ WebElement submitButton = driver.findElement(By.xpath("//input[@type='SUBMIT']"));
+ submitButton.click();
+
+ WebElement resultField = driver.findElement(By.cssSelector(".back"));
+ String actual = resultField.getText();
+ String expected = "100 mark in 1900 had the same buying power as";
+ Assert.assertTrue(actual.contains(expected),"Text is not the same");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/LegionOfJavaGroupTest.java b/src/test/java/school/redrover/old/LegionOfJavaGroupTest.java
new file mode 100644
index 0000000..5b85aec
--- /dev/null
+++ b/src/test/java/school/redrover/old/LegionOfJavaGroupTest.java
@@ -0,0 +1,217 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+import static org.openqa.selenium.By.className;
+import static org.testng.Assert.assertTrue;
+
+@Ignore
+public class LegionOfJavaGroupTest extends BaseTest {
+
+ @Test
+ public void testFerosorSearch() {
+
+ getDriver().get("https://ferosor.cl");
+ getDriver().manage().timeouts().pageLoadTimeout(Duration.ofSeconds(10));
+
+ WebElement textBox = getDriver().findElement(By.name("s"));
+ textBox.sendKeys("alimento");
+
+ getDriver().findElement(By.cssSelector("[type='submit']")).click();
+ getDriver().manage().timeouts().pageLoadTimeout(Duration.ofSeconds(10));
+
+ getDriver().get("https://ferosor.cl/jardin-y-mascotas/262-alimento-para-perro-cachorro-fit-formula-saco-10-kg-130622000123.html");
+ String result = String.valueOf(getDriver().findElement(By.className("h1")).getText());
+
+ Assert.assertEquals(result, "Alimento para Perro cachorro FIT FORMULA Saco 10 kg");
+ }
+
+ @Test
+ public void testFerosorLogin() {
+
+ getDriver().get("https://ferosor.cl");
+ getDriver().findElement(className("login")).click();
+
+ WebElement email = getDriver().findElement(By.className("form-control"));
+ email.sendKeys("test@test.com");
+
+ WebElement password = getDriver().findElement(By.className("js-child-focus"));
+ password.sendKeys("12345");
+
+ getDriver().findElement(By.id("submit-login")).click();
+ String result = String.valueOf( getDriver().findElement(By.className("page-header")).getText());
+
+ Assert.assertEquals(result, "Su cuenta");
+ }
+
+ @Ignore
+ @Test
+ public void testSearch() {
+
+ getDriver().get("https://www.amazon.com");
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ WebElement searchBox = getDriver().findElement(By.id("twotabsearchtextbox"));
+ WebElement submitButton = getDriver().findElement(By.id("nav-search-submit-button"));
+
+ searchBox.sendKeys("RaisedGardenBeds");
+ submitButton.click();
+
+ WebElement message = getDriver().findElement(By.xpath("//div[@class='a-sectiona-spacing-smalla-spacing-top-small']"));
+ String value = message.getText();
+ String[] arr = value.split("\"");
+ Assert.assertEquals(arr[1], "RaisedGardenBeds");
+
+ }
+ @Test
+ public void testFindElement(){
+ getDriver().get("https://www.w3schools.com/");
+
+ WebElement textBox=getDriver().findElement(By.id("search2"));
+ textBox.sendKeys("Java Tutorial");
+ WebElement button=getDriver().findElement(By.id("learntocode_searchbtn"));
+ button.click();
+ WebElement text=getDriver().findElement(By.xpath("//*[@id=\"leftmenuinnerinner\"]/a[1]"));
+
+ Assert.assertEquals(text.getText(),"Java HOME");
+ }
+
+ @Test
+ public void testSeleniumTrainingButton() {
+
+ getDriver().get("https://www.toolsqa.com/");
+
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
+ wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@href = '/selenium-training?q=headers']")));
+
+ WebElement button = getDriver().findElement(By.xpath("//a[@href = '/selenium-training?q=headers']"));
+ button.click();
+
+ WebElement text = getDriver().findElement(By.xpath("//div[@class='enroll__heading']"));
+ String value = text.getText();
+
+ Assert.assertEquals(value, "Selenium Certification Training | Enroll Now | Study Online");
+ }
+
+ @Test
+ public void testMyPinterest() {
+ WebDriver driver = getDriver();
+
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
+
+ driver.get("https://www.pinterest.com/");
+
+ String title = driver.getTitle();
+ Assert.assertEquals("Pinterest", title);
+
+ WebElement buttonLogIn = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(),'Log in')]")));
+ buttonLogIn.click();
+
+ WebElement userEmailInput = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='email']")));
+ userEmailInput.sendKeys("ii8281294@gmail.com");
+
+ WebElement userPasswordInput = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name='password']")));
+ userPasswordInput.sendKeys("test2024!");
+
+ WebElement buttonSubmit = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[@type='submit']")));
+ buttonSubmit.click();
+
+ WebElement homeWebElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Home")));
+
+ assertTrue(homeWebElement.isDisplayed());
+ assertTrue(homeWebElement.isEnabled());
+ }
+
+ @Test
+
+ public void testLogin(){
+ getDriver().get("https://practicetestautomation.com/practice-test-login/");
+ WebElement userName = getDriver().findElement(By.name("username"));
+ userName.sendKeys("student");
+ WebElement password = getDriver().findElement(By.name("password"));
+ password.sendKeys("Password123");
+ WebElement submitButton = getDriver().findElement(By.id("submit"));
+ submitButton.click();
+ WebElement result = getDriver().findElement(By.xpath("//h1"));
+ String resultText = result.getText();
+ Assert.assertEquals("Logged In Successfully", resultText);
+ }
+
+ @Test
+ public void testAnimalplanetShows() {
+
+ getDriver().get("https://www.animalplanet.com/");
+ getDriver().manage().window().maximize();
+
+ WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
+
+ WebElement aria_labelElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='siteLogo-Sz8OyJHj']")));
+ assertTrue(aria_labelElement.isDisplayed());
+ assertTrue(aria_labelElement.isEnabled());
+
+ WebElement shows = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[contains(text(),'Shows')]")));
+ shows.click();
+
+ WebElement ClickWildLife = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[contains(text(),'Wildlife')]")));
+ ClickWildLife.click();
+
+ WebElement listOfShows = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='subtabsWrapper-TXB_Y6RY']")));
+ assertTrue(listOfShows.isDisplayed());
+ assertTrue(listOfShows.isEnabled());
+ }
+
+ @Test
+ public void testSauseDemo() {
+ getDriver().get("https://www.saucedemo.com");
+
+ getDriver().findElement(By.id("user-name")).sendKeys("problem_user");
+ getDriver().findElement(By.id("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+
+ String message = getDriver().findElement(By.xpath("//span[@class='title']")).getText();
+
+ Assert.assertEquals(message, "Products");
+ }
+
+ @Test
+ public void testLiveMomentousStore() {
+ WebDriver driver = getDriver();
+ driver.get("https://www.livemomentous.com/");
+
+ WebElement menuButton = driver.findElement(By.xpath("//button[contains(@class, 'mobile-menu-trigger')]"));
+ menuButton.click();
+
+ WebElement bestSellingItems = driver.findElement(By.xpath("//li[contains(@class, 'navigation-list')]/a[@href = '/collections/best-sellers']"));
+ bestSellingItems.click();
+
+ WebElement rejectCookiesButton = driver.findElement(By.xpath("//div[@aria-label='close']"));
+ rejectCookiesButton.click();
+
+ WebElement item = driver.findElement(By.xpath("//h3[text() = 'Creatine']"));
+ Assert.assertTrue(item.isDisplayed());
+ }
+ @Test
+ public void testFindItem() throws InterruptedException {
+ WebDriver driver = getDriver();
+ driver.get("https://www.demoblaze.com/");
+
+ driver.findElement(By.xpath("//a[text() = 'Laptops']")).click();
+
+ Thread.sleep(1500);
+
+ WebElement item = driver.findElement(By.xpath("//h4[@class = 'card-title']/a[@href = 'prod.html?idp_=11']"));
+
+ Assert.assertEquals(item.getText(), "MacBook air");
+ }
+}
diff --git a/src/test/java/school/redrover/old/LoginNonexistentUserTest.java b/src/test/java/school/redrover/old/LoginNonexistentUserTest.java
new file mode 100644
index 0000000..c157af7
--- /dev/null
+++ b/src/test/java/school/redrover/old/LoginNonexistentUserTest.java
@@ -0,0 +1,39 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class LoginNonexistentUserTest {
+ @Test
+ public void loginNonexistentUser() {
+ WebDriver driver = new ChromeDriver();
+
+ driver.get("https://parabank.parasoft.com/parabank/index.htm");
+
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ WebElement usernameField = driver.findElement(By.name("username"));
+ usernameField.sendKeys("testUser");
+
+ WebElement passwordField = driver.findElement(By.name("password"));
+ passwordField.sendKeys("testPassword");
+
+ WebElement submitButton = driver.findElement(By.cssSelector("input.button"));
+ submitButton.click();
+
+ WebElement message = driver.findElement(By.cssSelector("p.error"));
+ String actualErrorMessage = message.getText();
+ Assert.assertEquals(actualErrorMessage, "The username and password could not be verified.");
+
+ driver.quit();
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/LoginTest.java b/src/test/java/school/redrover/old/LoginTest.java
new file mode 100644
index 0000000..89423f7
--- /dev/null
+++ b/src/test/java/school/redrover/old/LoginTest.java
@@ -0,0 +1,37 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class LoginTest {
+
+ @Test
+
+ public void testLogin(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://practice.expandtesting.com/login");
+
+ WebElement loginField = driver.findElement(By.name("username"));
+ loginField.sendKeys("Anna");
+
+ WebElement password = driver.findElement(By.id("password"));
+ password.sendKeys("123456789");
+
+ WebElement submitButton = driver.findElement(By.xpath("//button[@type='submit']"));
+ submitButton.click();
+
+ WebElement loginError = driver.findElement(By.xpath("//div[contains(@class,'alert alert-danger')]"));
+ String value = loginError.getText();
+
+ Assert.assertEquals(value,"Your username is invalid!");
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/Login_U_Test.java b/src/test/java/school/redrover/old/Login_U_Test.java
new file mode 100644
index 0000000..91c2c19
--- /dev/null
+++ b/src/test/java/school/redrover/old/Login_U_Test.java
@@ -0,0 +1,46 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class Login_U_Test {
+
+ @Test
+ public void testLoginUtest() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ driver.get("https://utest.com/");
+
+ WebElement loginButton = driver.findElement(By.xpath("(//a[@class='unauthenticated-nav-bar__link'])"));
+ loginButton.click();
+
+ WebElement emailField = driver.findElement(By.name("username"));
+ emailField.sendKeys("qwerty@gmail.com");
+
+ WebElement passwordField = driver.findElement(By.name("password"));
+ passwordField.sendKeys("qwerty1234");
+
+ WebElement sighInField = driver.findElement(By.name("login"));
+ sighInField.click();
+
+ WebElement errorField = driver.findElement(By.xpath("//div[@class='alert alert-error']//span[@class='kc-feedback-text']"));
+ String value = errorField.getText();
+
+ System.out.println("Error Message: " + value);
+
+ Assert.assertEquals(value, "Invalid username or password.");
+
+ driver.quit();
+ }
+}
+
+
diff --git a/src/test/java/school/redrover/old/LogoutTest.java b/src/test/java/school/redrover/old/LogoutTest.java
new file mode 100644
index 0000000..1332d8b
--- /dev/null
+++ b/src/test/java/school/redrover/old/LogoutTest.java
@@ -0,0 +1,38 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class LogoutTest {
+ @Test
+ public void TestMyTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement textArea = driver.findElement(By.id("user-name"));
+ textArea.sendKeys("standard_user");
+
+ WebElement textArea2 = driver.findElement(By.id("password"));
+ textArea2.sendKeys("secret_sauce");
+
+ WebElement button = driver.findElement(By.name("login-button"));
+ button.click();
+
+ WebElement button2= driver.findElement(By.className("bm-burger-button"));
+ button2.click();
+
+ WebElement logOut = driver.findElement(By.id("logout_sidebar_link"));
+ String value = logOut.getAccessibleName();
+
+ Assert.assertEquals(value,"Logout");
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/MyFirstSauceDemoTest.java b/src/test/java/school/redrover/old/MyFirstSauceDemoTest.java
new file mode 100644
index 0000000..8798c0a
--- /dev/null
+++ b/src/test/java/school/redrover/old/MyFirstSauceDemoTest.java
@@ -0,0 +1,31 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class MyFirstSauceDemoTest {
+ @Test
+ public void testTest(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com");
+
+ WebElement userName = driver.findElement(By.id("user-name"));
+ WebElement password = driver.findElement(By.id("password"));
+ WebElement submitButton = driver.findElement(By.id("login-button"));
+
+ userName.sendKeys("problem_user");
+ password.sendKeys("secret_sauce");
+ submitButton.click();
+
+ String message = driver.findElement(By.xpath("//span[@class='title']")).getText();
+ Assert.assertEquals(message,"Products" );
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/NaumovichTest.java b/src/test/java/school/redrover/old/NaumovichTest.java
new file mode 100644
index 0000000..6a98b84
--- /dev/null
+++ b/src/test/java/school/redrover/old/NaumovichTest.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class NaumovichTest {
+
+ @Test
+ public void testSauceDemo() {
+ String expectedResult = "https://www.saucedemo.com/inventory.html";
+
+ WebDriver driver = new ChromeDriver();
+
+ driver.get("https://www.saucedemo.com/");
+ WebElement name = driver.findElement(By.xpath("//input[@id='user-name']"));
+ name.sendKeys("standard_user");
+ WebElement passcode = driver.findElement(By.xpath("//input[@id='password']"));
+ passcode.sendKeys("secret_sauce");
+ driver.findElement(By.id("login-button")).click();
+
+ String actualResult = driver.getCurrentUrl();
+
+ Assert.assertEquals(actualResult, expectedResult);
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/Nyc311GetTitleTest.java b/src/test/java/school/redrover/old/Nyc311GetTitleTest.java
new file mode 100644
index 0000000..b500a53
--- /dev/null
+++ b/src/test/java/school/redrover/old/Nyc311GetTitleTest.java
@@ -0,0 +1,23 @@
+package school.redrover.old;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class Nyc311GetTitleTest extends AqaGroupBaseTest {
+
+ @Test
+ public void testGetNYC311Title(String[] args) {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://portal.311.nyc.gov/");
+
+ String expectedResult = "Home · NYC311";
+ String actualTitleResult = driver.getTitle();
+
+ Assert.assertEquals(actualTitleResult, expectedResult);
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/OvsTest.java b/src/test/java/school/redrover/old/OvsTest.java
new file mode 100644
index 0000000..842af0c
--- /dev/null
+++ b/src/test/java/school/redrover/old/OvsTest.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class OvsTest {
+ @Test
+ public void testGoogle() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://google.com");
+
+ WebElement text = driver.findElement(By.id("APjFqb"));
+ text.sendKeys("Selenium");
+
+ Thread.sleep(1000);
+
+ WebElement button = driver.findElement(By.className("gNO89b"));
+ button.click();
+
+ WebElement link = driver.findElement(By.xpath("//a[@href = 'https://www.selenium.dev/']/h3"));
+ String resultText = link.getText();
+
+ Assert.assertEquals(resultText, "Selenium");
+
+ driver.quit();
+ }
+}
+
diff --git a/src/test/java/school/redrover/old/PexelsTest.java b/src/test/java/school/redrover/old/PexelsTest.java
new file mode 100644
index 0000000..7d0cb20
--- /dev/null
+++ b/src/test/java/school/redrover/old/PexelsTest.java
@@ -0,0 +1,39 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+
+@Ignore
+public class PexelsTest {
+
+ @Test
+ public void testPexels() throws InterruptedException {
+
+ WebDriver driver = new ChromeDriver();
+
+ driver.get("https://www.pexels.com/");
+
+ WebElement text = driver.findElement(By.id("search"));
+ text.sendKeys("airplane");
+
+ Thread.sleep(1000);
+
+ WebElement button = driver.findElement(By.className("SearchInput_button__dQPLk"));
+ button.click();
+
+ Thread.sleep(1000);
+
+ String link = driver.getCurrentUrl();
+
+
+ Assert.assertEquals(link, "https://www.pexels.com/search/airplane/");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/PostmanTest.java b/src/test/java/school/redrover/old/PostmanTest.java
new file mode 100644
index 0000000..2dcbff4
--- /dev/null
+++ b/src/test/java/school/redrover/old/PostmanTest.java
@@ -0,0 +1,62 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+
+@Ignore
+public class PostmanTest {
+
+ @Test
+ public void testPostman() throws InterruptedException {
+// открытие браузера
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.postman.com/");
+// переход на Products - Download Postman
+ WebElement productButton = driver.findElement(By.xpath("//button/span[text() = 'Product']"));
+ productButton.click();
+ Thread.sleep(2000);
+ WebElement downloadPostman = driver.findElement(By.xpath("//button/a/div/span[text() = 'Download Postman']"));
+ downloadPostman.click();
+// сравнение названия вкладки с нужным
+ String title = driver.getTitle();
+ Assert.assertEquals("Download Postman | Get Started for Free", title);
+ Thread.sleep(2000);
+// прокрутка страницы вниз на 600 пикселей
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ js.executeScript("window.scrollBy(0, 600);");
+ Thread.sleep(2000);
+// нажатие на Try the Web Version
+ WebElement tryWeb = driver.findElement(By.xpath("//a[text() = 'Try the Web Version']"));
+ tryWeb.click();
+// переход на новую автоматически открытую вкладку для выполнения действий
+ ArrayList tabs = new ArrayList<>(driver.getWindowHandles()); // получение списка всех открытых вкладок
+ driver.switchTo().window(tabs.get(tabs.size() - 1)); // переключение на последнюю вкладку
+// заполнение полей для регистрации и нажатие на кнопку регистрации
+ Thread.sleep(2000);
+ WebElement email = driver.findElement(By.xpath("//input[@id = 'email']"));
+ email.sendKeys("rrehr56757rt46@mail.ru");
+ Thread.sleep(1000);
+ WebElement username = driver.findElement(By.xpath("//input[@id = 'username']"));
+ username.sendKeys("Geofr6863104");
+ Thread.sleep(1000);
+ WebElement password = driver.findElement(By.xpath("//input[@id = 'password']"));
+ password.sendKeys("_fhr776Yt5490)");
+ Thread.sleep(1000);
+ WebElement signUp = driver.findElement(By.xpath("//button[@id = 'sign-up-btn']"));
+ signUp.click();
+// ожидание открытия страницы и сравнение названия вкладки с нужным
+ Thread.sleep(10000);
+ String title2 = driver.getTitle();
+ Assert.assertEquals("Postman API Platform", title2);
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/QaDemoFirstTest.java b/src/test/java/school/redrover/old/QaDemoFirstTest.java
new file mode 100644
index 0000000..eccab79
--- /dev/null
+++ b/src/test/java/school/redrover/old/QaDemoFirstTest.java
@@ -0,0 +1,62 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Ignore
+public class QaDemoFirstTest {
+
+ @Test
+ public void testFindElementsOnMainPageAndCheck() {
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/");
+
+ String titleMain = driver.getTitle();
+ Assert.assertEquals(titleMain, "DEMOQA");
+
+
+ WebElement headerLink = driver.findElement(By.cssSelector("div#app header>a"));
+ String hrefValue = headerLink.getAttribute("href");
+ Assert.assertEquals(hrefValue, "https://demoqa.com/");
+
+
+ WebElement headerImg = driver.findElement(By.cssSelector("div#app header>a>img"));
+ String srcValue = headerImg.getAttribute("src");
+ String fileName = srcValue.substring(srcValue.lastIndexOf("/") + 1);
+ Assert.assertEquals(fileName,"Toolsqa.jpg");
+
+
+// div.home-banner>a>img[alt="Selenium Online Training"] проверить переход на страницу,
+// заголовок
+// div.home-body>div.category-cards как проверить длину списка и входящие элементы?
+ List listOfCards = driver.findElements(By.cssSelector("div.card-body"));
+ Assert.assertEquals(listOfCards.size(), 6);
+ System.out.println(listOfCards.size());
+
+// Как проверить имя каждого элемента без копирования текст? Сравнить 2 списка в цикле?
+ Assert.assertEquals(listOfCards.get(0).getText(), "Elements");
+ System.out.println(listOfCards.get(0).getText());
+
+ Assert.assertEquals(listOfCards.get(1).getText(), "Forms");
+ System.out.println(listOfCards.get(1).getText());
+
+
+ WebElement firstLabelElement = driver.findElement(By.cssSelector("div.card:first-child"));
+ firstLabelElement.click();
+
+ String titleMainElements = driver.getTitle();
+ Assert.assertEquals(titleMainElements, "DEMOQA");
+
+ driver.quit();
+
+ }
+
+}
diff --git a/src/test/java/school/redrover/old/RedRoverTest.java b/src/test/java/school/redrover/old/RedRoverTest.java
new file mode 100644
index 0000000..90897ff
--- /dev/null
+++ b/src/test/java/school/redrover/old/RedRoverTest.java
@@ -0,0 +1,42 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class RedRoverTest {
+
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ driver.get("https://www.selenium.dev/selenium/web/web-form.html");
+
+ WebElement textBox = driver.findElement(By.name("my-text"));
+ textBox.sendKeys("Selenium");
+
+ WebElement textArea = driver.findElement(By.name("my-textarea"));
+ textArea.sendKeys("Hello!");
+
+
+ WebElement submitButton = driver.findElement(By.className("btn"));//find button
+ submitButton.click();
+
+ WebElement message = driver.findElement(By.id("message"));
+ String value = message.getText();
+
+
+ Assert.assertEquals(value, "Received!");
+
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/RegisterAccountTutorialsninjaTest.java b/src/test/java/school/redrover/old/RegisterAccountTutorialsninjaTest.java
new file mode 100644
index 0000000..d63349e
--- /dev/null
+++ b/src/test/java/school/redrover/old/RegisterAccountTutorialsninjaTest.java
@@ -0,0 +1,52 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+@Ignore
+public class RegisterAccountTutorialsninjaTest extends BaseTest {
+
+ @Test
+ public void testRegisterAccountTutorialsninja() {
+ WebDriver driver = getDriver();
+ driver.get("https://tutorialsninja.com/demo/");
+
+ WebElement accountButton = driver.findElement(By.xpath("(//i[@class='fa fa-user'])"));
+ accountButton.click();
+
+ WebElement registerButton = driver.findElement(By.xpath("(//a[normalize-space()='Register'])[1]"));
+ registerButton.click();
+
+ WebElement firstNameField = driver.findElement(By.name("firstname"));
+ firstNameField.sendKeys("Anna");
+
+ WebElement lastNameField = driver.findElement(By.name("lastname"));
+ lastNameField.sendKeys("La");
+
+ WebElement emailField = driver.findElement(By.name("email"));
+ emailField.sendKeys("qwerty123@gmail");
+
+ WebElement telephoneField = driver.findElement(By.name("telephone"));
+ telephoneField.sendKeys("6469043333");
+
+ WebElement passwordField = driver.findElement(By.name("password"));
+ passwordField.sendKeys("qwerty123");
+
+ WebElement confirmPasswordField = driver.findElement(By.name("confirm"));
+ confirmPasswordField.sendKeys("qwerty123");
+
+ WebElement continueButton = driver.findElement(By.xpath("//input[@value='Continue']"));
+ continueButton.click();
+
+ WebElement errorAfterEmailField = driver.findElement(By.xpath("(//div[@class='text-danger'])[1]"));
+ String value = errorAfterEmailField.getText();
+
+ Assert.assertEquals(value, "E-Mail Address does not appear to be valid!");
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/SeleniumLoginTest.java b/src/test/java/school/redrover/old/SeleniumLoginTest.java
new file mode 100644
index 0000000..251c649
--- /dev/null
+++ b/src/test/java/school/redrover/old/SeleniumLoginTest.java
@@ -0,0 +1,84 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class SeleniumLoginTest {
+ @Test
+ public void testLogin() {
+
+ WebDriver driver = new ChromeDriver(); // Navigate to URL
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ driver.get("https://www.saucedemo.com/");
+ driver.manage().window().maximize();
+
+ WebElement loginLogo = driver.findElement(By.className("login_logo")); // Check logo
+ String loginLogoText = loginLogo.getText();
+ Assert.assertEquals("Swag Labs", loginLogoText);
+
+ WebElement usernameField = driver.findElement(By.id("user-name")); // Login
+ WebElement passwordField = driver.findElement(By.id("password"));
+ WebElement loginButton = driver.findElement(By.name("login-button"));
+
+ usernameField.sendKeys("standard_user");
+ passwordField.sendKeys("secret_sauce");
+ loginButton.click();
+
+ WebElement item1 = driver.findElement(By.linkText("Sauce Labs Backpack")); // Add item to cart
+ item1.click();
+
+ WebElement addToCartButton1 = driver.findElement(By.xpath("//*[@id=\"add-to-cart\"]"));
+ addToCartButton1.click();
+
+ WebElement backToProductsButton = driver.findElement(By.id("back-to-products"));
+ backToProductsButton.click();
+
+ WebElement cartBadge = driver.findElement(By.className("shopping_cart_badge"));
+ cartBadge.click();
+
+ WebElement checkoutButton = driver.findElement(By.name("checkout")); // Checkout
+ checkoutButton.click();
+
+ WebElement firstNameField = driver.findElement(By.id("first-name"));
+ firstNameField.sendKeys("Terrance");
+
+ WebElement lastNameField = driver.findElement(By.id("last-name"));
+ lastNameField.sendKeys("Hobbs");
+
+ WebElement postalCodeField = driver.findElement(By.name("postalCode"));
+ postalCodeField.sendKeys("666666");
+
+ WebElement continueButton = driver.findElement(By.id("continue"));
+ continueButton.click();
+
+ WebElement totalPrice = driver.findElement(By.xpath("//*[@id=\"checkout_summary_container\"]/div/div[2]/div[8]"));
+ String value = totalPrice.getText();
+ Assert.assertEquals("Total: $32.39", value);
+
+ WebElement finishButton = driver.findElement(By.id("finish"));
+ finishButton.click();
+
+ WebElement completeHeader = driver.findElement(By.className("complete-header"));
+ String headerText = completeHeader.getText();
+ Assert.assertEquals("Thank you for your order!", headerText);
+
+ WebElement backHomeButton = driver.findElement(By.name("back-to-products"));
+ backHomeButton.click();
+
+ WebElement burgerMenuButton = driver.findElement(By.id("react-burger-menu-btn")); // Logout
+ burgerMenuButton.click();
+
+ WebElement logoutSidebarLink = driver.findElement(By.id("logout_sidebar_link"));
+ logoutSidebarLink.click();
+
+ driver.quit();
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/school/redrover/old/SileniumTest.java b/src/test/java/school/redrover/old/SileniumTest.java
new file mode 100644
index 0000000..9bf87eb
--- /dev/null
+++ b/src/test/java/school/redrover/old/SileniumTest.java
@@ -0,0 +1,52 @@
+package school.redrover.old;
+
+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.support.ui.Wait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+import java.util.List;
+
+@Ignore
+public class SileniumTest extends BaseTest {
+ @Test
+ public void testFirst() {
+ getDriver().get("https://www.selenium.dev/");
+ WebElement title = getDriver().findElement(By.xpath("//h4[@class='h3 mb-3 selenium-webdriver']"));
+
+ Assert.assertEquals(title.getText(), "Selenium WebDriver");
+ }
+ @Test
+ public void testButton(){
+ getDriver().get("https://www.selenium.dev/");
+
+ WebElement dropButtonAbout= getDriver().findElement(By.xpath("//a[@id='navbarDropdown']"));
+ dropButtonAbout.click();
+
+ List dropdownItems = getDriver().findElements(By.xpath("//div[@class='dropdown-menu show']/a"));
+ int expectedItemCount = 8;
+
+ Assert.assertEquals(expectedItemCount, dropdownItems.size());
+ }
+ @Test
+ public void testList() {
+ getDriver().get("https://www.selenium.dev/");
+
+ WebElement dropButtonAbout = getDriver().findElement(By.xpath("//a[@id='navbarDropdown']"));
+ dropButtonAbout.click();
+
+ List dropdownItems = getDriver().findElements(By.xpath("//div[@class='dropdown-menu show']/a"));
+ String item1 = dropdownItems.get(0).getText();
+ System.out.println(item1);
+
+ Assert.assertEquals(item1, "About Selenium");
+ }
+ }
+
+
diff --git a/src/test/java/school/redrover/old/SimpleTest.java b/src/test/java/school/redrover/old/SimpleTest.java
new file mode 100644
index 0000000..0059bdf
--- /dev/null
+++ b/src/test/java/school/redrover/old/SimpleTest.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class SimpleTest {
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ driver.get("https://www.saucedemo.com/");
+
+
+ WebElement textBox = driver.findElement(By.name("user-name"));
+ textBox.sendKeys("Selenium");
+
+ WebElement login = driver.findElement(By.id("login-button"));
+ login.click();
+
+ WebElement message = driver.findElement(By.cssSelector("h3"));
+ String value = message.getText();
+ Assert.assertEquals("Epic sadface: Password is required", value);
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/SoferTest.java b/src/test/java/school/redrover/old/SoferTest.java
new file mode 100644
index 0000000..f6e06e5
--- /dev/null
+++ b/src/test/java/school/redrover/old/SoferTest.java
@@ -0,0 +1,34 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class SoferTest {
+
+ @Test
+ public void testLogin(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement textBoxUsername = driver.findElement(By.cssSelector("#user-name"));
+ textBoxUsername.sendKeys("standard_user");
+
+ WebElement textBoxPassword = driver.findElement(By.cssSelector("#password"));
+ textBoxPassword.sendKeys("secret_sauce");
+
+ WebElement submitButton = driver.findElement(By.cssSelector("#login-button"));
+ submitButton.click();
+
+ WebElement message = driver.findElement(By.cssSelector("#header_container > div.primary_header > div.header_label > div"));
+ String value = message.getText();
+ Assert.assertEquals(value, "Swag Labs");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/SprinkleSystemTestLogin.java b/src/test/java/school/redrover/old/SprinkleSystemTestLogin.java
new file mode 100644
index 0000000..c0dffca
--- /dev/null
+++ b/src/test/java/school/redrover/old/SprinkleSystemTestLogin.java
@@ -0,0 +1,42 @@
+package school.redrover.old;
+
+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.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.io.Console;
+import java.time.Duration;
+
+@Ignore
+public class SprinkleSystemTestLogin {
+ @Test
+ public void testGoogle() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://project-atlas.dev/");
+ WebElement button = driver.findElement(By.xpath("//a[@href = '/dashboard']"));
+ button.click();
+
+ WebElement text = driver.findElement(By.name("email"));
+ text.sendKeys("userFirst@yopmail.com");
+
+ text = driver.findElement(By.name("password"));
+ text.sendKeys("User@1");
+
+ button = driver.findElement(By.xpath("//button[@type='submit']"));
+ button.click();
+
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
+ WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@role='status']")));
+ String resultText = element.getText();
+ Assert.assertEquals(resultText, "server_errors.UserNotFound");
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/TangaTest.java b/src/test/java/school/redrover/old/TangaTest.java
new file mode 100644
index 0000000..67e4edf
--- /dev/null
+++ b/src/test/java/school/redrover/old/TangaTest.java
@@ -0,0 +1,37 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class TangaTest {
+ @Test
+ public void tangaTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.tanga.com/");
+
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ WebElement textBox = driver.findElement(By.name("q"));
+ textBox.sendKeys("5959595959");
+// textBox.sendKeys(Keys.ENTER);
+
+ WebElement button = driver.findElement(By.xpath("//button[@aria-label='Search']"));
+ button.click();
+
+ WebElement message = driver.findElement(By.xpath("//h3"));
+ String value = message.getText();
+
+ Assert.assertEquals("No products found", value);
+
+ driver.quit();
+
+ }
+}
diff --git a/src/test/java/school/redrover/old/TeaPartyGroupTest.java b/src/test/java/school/redrover/old/TeaPartyGroupTest.java
new file mode 100644
index 0000000..fbda459
--- /dev/null
+++ b/src/test/java/school/redrover/old/TeaPartyGroupTest.java
@@ -0,0 +1,169 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.time.Duration;
+
+@Ignore
+public class TeaPartyGroupTest extends BaseTest {
+
+ @Test
+ public void idDemoTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+ WebElement loginPassword = driver.findElement(By.name("password"));
+ loginPassword.sendKeys("secret_sauce");
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+ WebElement menu = driver.findElement(By.id("react-burger-menu-btn"));
+ menu.click();
+ }
+
+ @Test
+ public void tgSprinkleSystemTest() throws InterruptedException {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://project-atlas.dev/");
+ WebElement button = driver.findElement(By.xpath("//a[@href = '/dashboard']"));
+ button.click();
+ WebElement text = driver.findElement(By.name("email"));
+ text.sendKeys("userFirst@yopmail.com");
+ text = driver.findElement(By.name("password"));
+ text.sendKeys("User@1");
+ button = driver.findElement(By.xpath("//button[@type='submit']"));
+ button.click();
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
+ WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@role='status']")));
+ String resultText = element.getText();
+ Assert.assertEquals(resultText,"server_errors.UserNotFound");
+ driver.quit();
+ }
+ @Test
+ public void tgDemoTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+ WebElement loginPassword = driver.findElement(By.name("password"));
+ loginPassword.sendKeys("secret_sauce");
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+ WebElement menu = driver.findElement(By.id("react-burger-menu-btn"));
+ menu.click();
+ String allItemsText = menu.getText();
+ Assert.assertEquals(allItemsText, "Open Menu");
+ driver.quit();
+ }
+
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+ WebElement textBox = driver.findElement(By.id("user-name"));
+ textBox.sendKeys("visual_user");
+ WebElement textBox2 = driver.findElement(By.id("password"));
+ textBox2.sendKeys("secret_sauce");
+ WebElement login = driver.findElement(By.id("login-button"));
+ login.click();
+ WebElement menu = driver.findElement(By.id("react-burger-menu-btn"));
+ String nMenu = menu.getText();
+ assert menu.getText().equals(nMenu) : "All Items";
+ menu.click();
+ }
+
+ @Test
+ public void alenaTest(){
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+ WebElement loginPassword = driver.findElement(By.name("password"));
+ loginPassword.sendKeys("secret_sauce");
+ WebElement loginButton = driver.findElement(By.id("login-button"));
+ loginButton.click();
+ WebElement menu = driver.findElement(By.id("react-burger-menu-btn"));
+ String nMenu = menu.getText();
+ assert menu.getText().equals(nMenu) : "All Items";
+ menu.click();
+ }
+ @Test
+ public void natashaTest(){
+
+ WebDriver driver =new ChromeDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ WebElement login = driver.findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+
+ WebElement loginPassword= driver.findElement(By.name("password"));
+ loginPassword.sendKeys("secret_sauce");
+
+ WebElement loginButton=driver.findElement(By.id("login-button"));
+ loginButton.click();
+ driver.quit();
+ }
+
+ @Test
+ public void natashaFarfetchTest () {
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://www.farfetch.com/designers/women");
+
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).sendKeys("Valentino");
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).click();
+
+ driver.get("https://www.farfetch.com/shopping/women/items.aspx");
+
+ driver.findElement(By.xpath("//input[@data-component='SearchInputControlled']")).sendKeys("YSL Heels");
+ driver.findElement(By.xpath("//input[@data-testid='search-input']")).click();
+ driver.quit();
+
+ }
+
+
+ @Test // Testing that download button redirects user to App store preview, Lena's Test
+ public void downloadButtonTest() {
+
+ getDriver().get("https://fyi.fyi/");
+
+ WebElement link = getDriver().findElement(By.xpath("//a[@href='https://fyi.me/app'] "));
+ link.click();
+
+ WebElement Appstore = getDriver().findElement(By.className("we-localnav__title__product"));
+ String value = Appstore.getText();
+ Assert.assertEquals(value,"Mac App Store" );
+ String currentURL = getDriver().getCurrentUrl();
+ Assert.assertEquals(currentURL, "https://apps.apple.com/us/app/fyi-ai-focus-your-ideas/id1554341467");
+
+ }
+
+ @Test
+ public void elenaTest() {
+
+ getDriver().get("https://www.saucedemo.com/");
+
+ WebElement login = getDriver().findElement(By.id("user-name"));
+ login.sendKeys("standard_user");
+ WebElement loginPassword = getDriver().findElement(By.name("password"));
+ loginPassword.sendKeys("secret_sauce");
+ WebElement loginButton = getDriver().findElement(By.id("login-button"));
+ loginButton.click();
+ WebElement menu = getDriver().findElement(By.id("react-burger-menu-btn"));
+ menu.click();
+ String allItemsText = menu.getText();
+ Assert.assertEquals(allItemsText, "Open Menu");
+
+ }
+ }
+
+
diff --git a/src/test/java/school/redrover/old/TestCraftersTest.java b/src/test/java/school/redrover/old/TestCraftersTest.java
new file mode 100644
index 0000000..33a1ee5
--- /dev/null
+++ b/src/test/java/school/redrover/old/TestCraftersTest.java
@@ -0,0 +1,215 @@
+//This class for @test_crafters group.
+//URL for test: https://tutorialsninja.com/demo/
+
+package school.redrover.old;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+@Ignore
+public class TestCraftersTest extends BaseTest {
+ private final static String URL = "https://tutorialsninja.com/demo/";
+
+ @Test
+ public void testMainPageView() {
+ initialization(URL);
+ String featered = getDriver().findElement(By.xpath("//h3")).getText();
+
+ Assert.assertEquals(featered, "Featured");
+ }
+ @Test(description = "default currency must be $")
+ public void testDefaultCurrency() {
+ initialization(URL);
+ String currentCurrency = getDriver().findElement(By.xpath("//strong")).getText();
+ List itemPrices = getDriver().findElements(By.className("price"));
+
+ Assert.assertEquals(currentCurrency, "$");
+
+ for (WebElement price: itemPrices) {
+ String exTax = new StringBuilder(price.getText().substring(price.getText().indexOf(":")+1)).toString();
+ Assert.assertEquals(price.getText().charAt(0), '$');
+ Assert.assertEquals(exTax.charAt(0), '$');
+ }
+ }
+
+ @Test
+ public void testPound() {
+ initialization(URL);
+ getDriver().findElement(By.id("form-currency")).click();
+ getDriver().findElement(By.xpath("//*[@name='GBP']")).click();
+ String currentCurrency = getDriver().findElement(By.xpath("//strong")).getText();
+ List itemPrices = getDriver().findElements(By.className("price"));
+
+ Assert.assertEquals(currentCurrency, "£");
+
+ for (WebElement price: itemPrices) {
+ String exTax = new StringBuilder(price.getText().substring(price.getText().indexOf(":")+1)).toString();
+
+ Assert.assertEquals(price.getText().charAt(0), '£');
+ Assert.assertEquals(exTax.charAt(0), '£');
+ }
+ }
+
+ @Test
+ public void testEuro() {
+ initialization(URL);
+ getDriver().findElement(By.id("form-currency")).click();
+ getDriver().findElement(By.xpath("//*[@name='EUR']")).click();
+ String currentCurrency = getDriver().findElement(By.xpath("//strong")).getText();
+ List itemsPrice = getDriver().findElements(By.className("price"));
+
+ Assert.assertEquals(currentCurrency, "€");
+
+ for (WebElement price: itemsPrice) {
+ String exTax = new StringBuilder(price.getText().substring(price.getText().indexOf(":")+1)).toString();
+ String totalPrice = new StringBuilder(price.getText().substring(0, price.getText().indexOf("€")+1)).toString();
+
+ Assert.assertTrue(totalPrice.contains("€"));
+ Assert.assertTrue(exTax.contains("€"));
+ }
+ }
+
+ @Test
+ public void testPhoneIcoRedirect() {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//i[@class='fa fa-phone']")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(),"https://tutorialsninja.com/demo/index.php?route=information/contact");
+ }
+
+ @Test
+ public void testPhoneNumber() {
+ initialization(URL);
+ String phoneNumber = getDriver().findElement(By.xpath("//*[@id='top-links']/ul/li[1]/span")).getText();
+
+ Assert.assertEquals(phoneNumber, "123456789");
+ }
+
+ @Test
+ public void testHeaderMyAccountRegisterRedirect() {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//li[@class='dropdown']//span[contains(text(),'My Account')]")).click();
+ getDriver().findElement(By.xpath("//*[contains(text(),'Register')]")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://tutorialsninja.com/demo/index.php?route=account/register");
+ }
+
+ @Test
+ public void testHeaderLoginRedirect() {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//li[@class='dropdown']//span[contains(text(),'My Account')]")).click();
+ getDriver().findElement(By.xpath("//*[contains(text(),'Login')]")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://tutorialsninja.com/demo/index.php?route=account/login");
+ }
+
+ @Test(description = "without login")
+ public void testWishListRedirec() {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//*[@class='fa fa-heart']")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://tutorialsninja.com/demo/index.php?route=account/login");
+ }
+
+ @Test
+ public void testWishListCounter() throws InterruptedException {
+ initialization(URL);
+ List addItems = getDriver().findElements(By.xpath("//*[@data-original-title='Add to Wish List']"));
+
+ for (int i = 0; i < addItems.size(); i++) {
+ addItems.get(i).click();
+
+ Thread.sleep(1000L);
+
+ String currentSign = getDriver()
+ .findElement(By.xpath("//*[@id='wishlist-total']/span"))
+ .getText();
+ Integer currentCount = Integer.parseInt(currentSign.substring(currentSign.indexOf('(')+1, currentSign.indexOf(')')));
+ Assert.assertEquals(currentCount, i+1);
+ }
+ }
+
+ @Test
+ public void testShopingCartRedirect () {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//*[contains(text(),'Shopping Cart')]")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://tutorialsninja.com/demo/index.php?route=checkout/cart");
+ }
+
+ @Test
+ public void testAddShopingCart () {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//*[@class='product-thumb transition']//img[@alt='MacBook']")).click();
+ getDriver().findElement(By.xpath("//button[contains(text(),'Add to Cart')]")).click();
+ getDriver().findElement(By.xpath("//span[@id='cart-total']")).click();
+
+ Assert.assertTrue(getDriver().findElement(By.xpath("//ul[@class='dropdown-menu pull-right']//a[text()='MacBook']")).isEnabled());
+ }
+
+ @Test
+ public void testCheckoutRedirect() {
+ initialization(URL);
+ getDriver().findElement(By.xpath("//*[contains(text(),'Checkout')]")).click();
+
+ Assert.assertEquals(getDriver().getCurrentUrl(), "https://tutorialsninja.com/demo/index.php?route=checkout/cart");
+ }
+ @Test
+ public void testHomePageTitle() {
+ initialization(URL);
+ String actualTitle = getDriver().getTitle();
+ String expectedTitle = "Your Store";
+ Assert.assertEquals(actualTitle, expectedTitle);
+ }
+
+ @Test
+ public void testRegister () {
+ getDriver().get(URL);
+
+ getDriver().findElement(By.linkText("My Account")).click();
+ getDriver().findElement(By.linkText("Register")).click();
+ getDriver().findElement(By.id("input-firstname")).sendKeys("TestFirstName2");
+ getDriver().findElement(By.id("input-lastname")).sendKeys("TestLastName2");
+ getDriver().findElement(By.id("input-email")).sendKeys("Kattin@gmail.com");
+ getDriver().findElement(By.id("input-telephone")).sendKeys("1234567891");
+ getDriver().findElement(By.id("input-password")).sendKeys("12345test");
+ getDriver().findElement(By.id("input-confirm")).sendKeys("12345test");
+ getDriver().findElement(By.name("agree")).click();
+ getDriver().findElement(By.xpath("//input[@class= 'btn btn-primary']")).click();
+
+ String actualTitle = getDriver().getTitle();
+ String expectedTitle = "Your Account Has Been Created!";
+ Assert.assertEquals(actualTitle, expectedTitle);
+ }
+
+ public void initialization(String url) {
+ getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
+ getDriver().manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
+ getDriver().get(url);
+
+ }
+ @Test
+ public void testRegisterAccountWithErrorEmail() {
+
+ getDriver().get(URL);
+
+ getDriver().findElement(By.xpath("(//i[@class='fa fa-user'])")).click();
+ getDriver().findElement(By.xpath("(//a[normalize-space()='Register'])[1]")).click();
+ getDriver().findElement(By.name("firstname")).sendKeys("Anna");
+ getDriver().findElement(By.name("lastname")).sendKeys("La");
+ getDriver().findElement(By.name("email")).sendKeys("qwerty123@gmail");
+ getDriver().findElement(By.name("telephone")).sendKeys("6469043333");
+ getDriver().findElement(By.name("password")).sendKeys("qwerty123");
+ getDriver().findElement(By.name("confirm")).sendKeys("qwerty123");
+ getDriver().findElement(By.xpath("//input[@value='Continue']")).click();
+
+ WebElement errorAfterEmailField = getDriver().findElement(By.xpath("(//div[@class='text-danger'])[1]"));
+ String value = errorAfterEmailField.getText();
+ Assert.assertEquals(value, "E-Mail Address does not appear to be valid!");
+ }
+}
diff --git a/src/test/java/school/redrover/old/TestHerokuapp.java b/src/test/java/school/redrover/old/TestHerokuapp.java
new file mode 100644
index 0000000..9df16b2
--- /dev/null
+++ b/src/test/java/school/redrover/old/TestHerokuapp.java
@@ -0,0 +1,27 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class TestHerokuapp {
+ @Test
+ public void testHerokuapp() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://the-internet.herokuapp.com/");
+
+ WebElement textBox = driver.findElement(By.cssSelector("#content > ul > li:nth-child(1) > a"));
+ textBox.click();
+
+ WebElement message = driver.findElement(By.xpath("/html/body/div[2]/div/div/h3"));
+ String value = message.getText();
+ Assert.assertEquals("A/B Test Variation 1", value);
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/TestQADemo.java b/src/test/java/school/redrover/old/TestQADemo.java
new file mode 100644
index 0000000..64881e0
--- /dev/null
+++ b/src/test/java/school/redrover/old/TestQADemo.java
@@ -0,0 +1,26 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class TestQADemo {
+ @Test
+ public void testToolsQA() {
+
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://demoqa.com/text-box");
+
+ String title = driver.getTitle();
+ Assert.assertEquals(title, "DEMOQA");
+
+ WebElement primaryImage = driver.findElement(By.xpath("//img[@src = '/images/Toolsqa.jpg']"));
+ Assert.assertTrue(primaryImage.isDisplayed());
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/TeststoreTest.java b/src/test/java/school/redrover/old/TeststoreTest.java
new file mode 100644
index 0000000..47f4bea
--- /dev/null
+++ b/src/test/java/school/redrover/old/TeststoreTest.java
@@ -0,0 +1,31 @@
+package school.redrover.old;
+
+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.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+@Ignore
+public class TeststoreTest {
+ @Test
+ public void firstTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://teststore.automationtesting.co.uk/index.php");
+
+ WebElement clothes = driver.findElement(By.cssSelector("#category-3 > a"));
+ Actions actions = new Actions(driver);
+ actions.moveToElement(clothes).perform();
+
+ WebElement men = driver.findElement(By.cssSelector("#category-4 > a"));
+ men.click();
+
+ WebElement Men = driver.findElement(By.className("h1"));
+
+ Assert.assertEquals(Men.getText(), "MEN");
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/UnderdogsGroupTest.java b/src/test/java/school/redrover/old/UnderdogsGroupTest.java
new file mode 100644
index 0000000..173a327
--- /dev/null
+++ b/src/test/java/school/redrover/old/UnderdogsGroupTest.java
@@ -0,0 +1,261 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+import java.util.List;
+
+@Ignore
+public class UnderdogsGroupTest extends BaseTest {
+ private final static String URL_HOMEPAGE = "https://demoqa.com/";
+ @Test
+ public void testDemoQAInput() {
+ getDriver().get("https://demoqa.com/");
+ getDriver().findElement(By.id("close-fixedban")).click();
+ getDriver().findElement(By.xpath("//div[@class='category-cards']/div[1]")).click();
+ getDriver().findElement(By.xpath("//span[text()='Text Box']")).click();
+ String name = "test";
+ getDriver().findElement(By.id("userName")).sendKeys(name);
+ getDriver().findElement(By.id("submit")).click();
+ String result = getDriver().findElement(By.id("name")).getText();
+
+ Assert.assertEquals(result, "Name:" + name);
+ }
+
+
+ @Test
+ public void testElementsTextBox() {
+ getDriver().get("https://demoqa.com/");
+ getDriver().findElement(By.xpath("//*[@Class=\"card mt-4 top-card\"]")).click();
+ getDriver().findElement(By.xpath("//*[contains(text(),'Text Box')]")).click();
+ String email = "test@gmail.com";
+
+ getDriver().findElement(By.id("userEmail")).sendKeys(email);
+ getDriver().findElement(By.id("submit")).click();
+ String result = getDriver().findElement(By.id("email")).getText();
+
+ Assert.assertEquals(result, "Email:" + email);
+ }
+
+ @Test
+ public void testCheckTheQuantityInTheCart() {
+ getDriver().get("https://natr.com.tr/en/");
+ getDriver().findElement(By.xpath("//li[@class='search']")).click();
+
+ WebElement searchField = getDriver().findElement(By.xpath("//input[@id='dgwt-wcas-search-input-2']"));
+ searchField.sendKeys("Vitamin");
+
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(searchField).sendKeys(org.openqa.selenium.Keys.ENTER).perform();
+
+ getDriver().findElement(By.xpath("//span[@class='onsale']/following-sibling::img[@src='https://natr.com.tr/wp-content/uploads/Витамин-C1.jpg-300x300.png']")).click();
+ getDriver().findElement(By.xpath("//button[@name='add-to-cart']")).click();
+ getDriver().findElement(By.xpath("//a[@title='View your shopping cart']")).click();
+
+ String quantity = getDriver().findElement(By.xpath("//div[@class='quantity']//input[@value='1']")).getAttribute("value");
+
+ Assert.assertEquals(quantity, "1");
+ }
+
+ @Test
+ public void testCheckBox() {
+ getDriver().get("https://demoqa.com/checkbox");
+ getDriver().manage().window().maximize();
+
+ getDriver()
+ .findElement(By.xpath("//div[@id='tree-node']/ol/li/span/button"))
+ .click();
+ getDriver().findElement(By.xpath("//*[@id='tree-node']//li[2]//button"))
+ .click();
+ getDriver().findElement(By.xpath("//*[@for='tree-node-workspace']/span"))
+ .click();
+
+ Assert.assertEquals(getDriver().findElement(By.id("result")).getText(),
+ "You have selected :\nworkspace\nreact\nangular\nveu");
+ }
+
+ @Test
+ public void testHomeCheckbox() {
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ getDriver().get("https://demoqa.com/checkbox");
+// getDriver().findElement(new By.ByCssSelector("[class='rct-icon rct-icon-uncheck']")).click();
+ getDriver().findElement(By.xpath("//*[@for='tree-node-home']")).click();
+
+ WebElement results = getDriver().findElement(By.id("result"));
+ String textHome = """
+ You have selected :
+ home
+ desktop
+ notes
+ commands
+ documents
+ workspace
+ react
+ angular
+ veu
+ office
+ public
+ private
+ classified
+ general
+ downloads
+ wordFile
+ excelFile""";
+
+ Assert.assertEquals(results.getText(), textHome);
+ }
+
+ @Ignore
+ @Test
+ public void numberOfTheCarsPresented() {
+ WebDriver driver = new ChromeDriver();
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
+ driver.get("https://av.by/");
+ wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//button[@class='button button--default button--block button--large']"))));
+ driver.findElement(By.xpath("//button[@class='button button--default button--block button--large']")).click();
+ ((JavascriptExecutor) driver).executeScript("javascript:window.scrollBy(0,500)");
+ List carsModels = driver.findElements(By.xpath("//span[@class='catalog__title']"));
+ Assert.assertEquals(carsModels.size(), 30);
+ driver.quit();
+ }
+
+ @Test
+ public void testRightSideAdvertisement() {
+ getDriver().get("https://demoqa.com/");
+ getDriver().manage().window().maximize();
+
+ getDriver().findElement(By.xpath("//h5[contains(text(),'Elements')]")).click();
+
+ Assert.assertTrue(getDriver().findElement(By.id("RightSide_Advertisement")).isDisplayed());
+ }
+
+
+ @Test
+ public void testAddToCartButton() throws InterruptedException {
+ getDriver().get("https://natr.com.tr/shop/?s=Vitamin&post_type=product&dgwt_wcas=1");
+ getDriver().manage().window().maximize();
+
+ WebElement buttonAddToСart = getDriver().findElement(By.xpath("(//a[@class ='button product_type_simple add_to_cart_button ajax_add_to_cart'])[1]"));
+
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(buttonAddToСart).click(buttonAddToСart).perform();
+
+ String order = buttonAddToСart.getAttribute("aria-label").replaceAll(".*“(.*)”.*", "$1");
+ Thread.sleep(4000);
+ WebElement buttonShoppingBag = getDriver().findElement(By.xpath("(//span[@class = 'cart-items-count count header-icon-counter'])[1]"));
+ buttonShoppingBag.click();
+
+ Thread.sleep(4000);
+
+ String element = getDriver().findElement(By.xpath("(//li[@class='woocommerce-mini-cart-item mini_cart_item']/a)[2]")).getText();
+
+ Assert.assertEquals(element.trim(), order);
+ }
+ @Test
+ public void testVerifyTitle() {
+ getDriver().get(URL_HOMEPAGE);
+
+ Assert.assertEquals(getDriver().getTitle(), "DEMOQA", "Not equal your message with title of page");
+ }
+
+ @Test
+ public void testSearchByName() throws InterruptedException {
+ getDriver().get("https://uk.coach.com/");
+
+ getDriver().findElement(By.xpath("//p[contains(text(),'Women')]")).click();
+ Thread.sleep(4000);
+
+ getDriver().findElement(By.xpath("//div[contains(text(),'Backpacks')]")).click();
+ Thread.sleep(4000);
+
+ WebElement actualText = getDriver().findElement(By.xpath("//h1[@class = 'chakra-text css-zy3pag']"));
+
+ Assert.assertEquals(actualText.getText(), "WOMEN'S BACKPACKS");
+ }
+
+ @Test
+ public void testAutomationTestingOnline() throws InterruptedException {
+ getDriver().get("https://automationintesting.online/");
+
+ String name = "Anhelina";
+ WebElement fieldName = getDriver().findElement(By.xpath("//*[@id=\"name\"]"));
+ fieldName.sendKeys(name);
+
+ WebElement fieldEmail = getDriver().findElement(By.xpath("//*[@id=\"email\"]"));
+ fieldEmail.sendKeys("qa@mail.com");
+
+ WebElement fieldPhone = getDriver().findElement(By.xpath("//*[@id=\"phone\"]"));
+ fieldPhone.sendKeys("01234567890");
+
+ String subject = "rooms";
+ WebElement fieldSubject = getDriver().findElement(By.xpath("//*[@id=\"subject\"]"));
+ fieldSubject.sendKeys(subject);
+
+ WebElement fieldMessage = getDriver().findElement(By.xpath("//*[@id=\"description\"]"));
+ fieldMessage.sendKeys("Hello. I'm Anhelina.");
+
+ WebElement buttonSubmit = getDriver().findElement(By.xpath("//*[@id=\"submitContact\"]"));
+ buttonSubmit.click();
+
+ Thread.sleep(500);
+ WebElement actualText = getDriver().findElement(By.xpath("//div[@class = \"row contact\"]/div[2]"));
+
+ Assert.assertEquals(actualText.getText(), "Thanks for getting in touch " + name + "!" + "\n"
+ + "We'll get back to you about" + "\n"
+ + subject + "\n"
+ + "as soon as possible.");
+
+ }
+
+ @Test
+ public void testMainTest() throws InterruptedException {
+ getDriver().get("https://art-complex.ru/brand/kl-acoustics/");
+ Thread.sleep(2000);
+ getDriver().findElement(By.id("mod_search_searchword")).sendKeys("INVOTONE H829");
+ Thread.sleep(3000);
+ getDriver().findElement(By.id("sr0")).click();
+ getDriver().findElement(By.id("tocart_3341")).click();
+ getDriver().findElement(By.id("count_3341")).sendKeys("2");
+ String resultText = getDriver().findElement(By.className("shop-cart-div-1")).getText();
+
+ Assert.assertEquals(resultText, "Минимальный заказ в нашем магазине 10 000 руб.");
+ }
+
+ @Test
+ public void testSauceDemo() throws InterruptedException {
+ getDriver().get("https://www.saucedemo.com/");
+ getDriver().manage().window().maximize();
+
+ Assert.assertEquals ("Swag Labs", getDriver().findElement (By.className("login_logo")).getText());
+
+ getDriver().findElement(By.id("user-name")).sendKeys("standard_user");
+ getDriver().findElement(By.id("password")).sendKeys("secret_sauce");
+ getDriver().findElement(By.id("login-button")).click();
+
+ Thread.sleep(1000);
+
+ Assert.assertEquals ("Swag Labs", getDriver().findElement (By.className("app_logo")).getText());
+ }
+
+ @Test
+ public void testArticleTitle() {
+ getDriver().manage().window().maximize();
+ getDriver().get("https://en.wikipedia.org/wiki/Wikipedia");
+ WebElement articleTitleElement = getDriver().findElement(By.className("mw-page-title-main"));
+ String articleTitle = articleTitleElement.getText();
+ String expectedTitle = "Wikipedia";
+ Assert.assertEquals(articleTitle, expectedTitle, "Page title does not equals to the expected title");
+ }
+
+}
diff --git a/src/test/java/school/redrover/old/WikiTest.java b/src/test/java/school/redrover/old/WikiTest.java
new file mode 100644
index 0000000..eb29e5b
--- /dev/null
+++ b/src/test/java/school/redrover/old/WikiTest.java
@@ -0,0 +1,30 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+import java.time.Duration;
+import static org.testng.Assert.assertEquals;
+
+@Ignore
+public class WikiTest extends BaseTest {
+
+ @Test
+ public void testWiki() {
+ getDriver().get("https://www.wikipedia.org/");
+
+ getDriver().manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ WebElement textBox = getDriver().findElement(By.id("searchInput"));
+ WebElement searchInputButton = getDriver().findElement(By.xpath("//*[@id='search-form']/fieldset/button"));
+
+ textBox.sendKeys("test");
+ searchInputButton.click();
+
+ WebElement message = getDriver().findElement(By.xpath("//*[@id='firstHeading']/span"));
+ String value = message.getText();
+ assertEquals(value, "Test");
+ }
+}
diff --git a/src/test/java/school/redrover/old/WikipediaTest.java b/src/test/java/school/redrover/old/WikipediaTest.java
new file mode 100644
index 0000000..a2baf29
--- /dev/null
+++ b/src/test/java/school/redrover/old/WikipediaTest.java
@@ -0,0 +1,51 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class WikipediaTest {
+
+ private final static String URL = "https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0";
+
+ @Test
+ public void testSearchWord() throws InterruptedException {
+
+ String expectedResult = "Абракадабра";
+
+ WebDriver driver = new ChromeDriver();
+ driver.manage().window().maximize();
+ driver.get(URL);
+
+ driver.findElement(By.xpath("//input[@id='searchInput']")).sendKeys("Абракадабра");
+ Thread.sleep(2000);
+ driver.findElement(By.xpath("//input[@id='searchButton']")).click();
+ Thread.sleep(2000);
+
+ String value = driver.findElement(By.xpath("//h1[@id='firstHeading']")).getText();
+
+ Assert.assertEquals(value, expectedResult);
+
+ driver.quit();
+ }
+
+ @Test
+ public void testTest() {
+ WebDriver driver = new ChromeDriver();
+ driver.get("https://ru.wikipedia.org/w/index.php?title=%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F&action=edit");
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+ WebElement articuiLink = driver.findElement(By.id("ca-nstab-main"));
+ articuiLink.click();
+ String value = driver.findElement(By.cssSelector(".mw-page-title-main")).getText();
+
+ Assert.assertEquals(value, "Википедия");
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/WildberriesTest.java b/src/test/java/school/redrover/old/WildberriesTest.java
new file mode 100644
index 0000000..657f93a
--- /dev/null
+++ b/src/test/java/school/redrover/old/WildberriesTest.java
@@ -0,0 +1,36 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+import java.time.Duration;
+
+@Ignore
+public class WildberriesTest {
+ @Test
+ public void testWild() throws InterruptedException {
+ WebDriver driver = new FirefoxDriver();
+ driver.get("https://www.wildberries.ru/");
+
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
+
+ WebElement profilButton = driver.findElement(By.xpath("//*[@id='basketContent']/div[2]/a"));
+ profilButton.click();
+
+ WebElement phoneInput = driver.findElement(By.xpath("//input[@class='input-item']"));
+ phoneInput.sendKeys("89675645342");
+
+ WebElement kodButton = driver.findElement(By.id("requestCode"));
+ kodButton.click();
+
+ WebElement messageText = driver.findElement(By.xpath("//*[@class='form-block form-block--captcha']//*[@class='sign-in-page__title']"));
+ Assert.assertEquals("Введите код с картинки", messageText.getText());
+
+ driver.quit();
+ }
+}
diff --git a/src/test/java/school/redrover/old/WithoutGroupTest.java b/src/test/java/school/redrover/old/WithoutGroupTest.java
new file mode 100644
index 0000000..855ae5d
--- /dev/null
+++ b/src/test/java/school/redrover/old/WithoutGroupTest.java
@@ -0,0 +1,69 @@
+package school.redrover.old;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.Assert;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+import school.redrover.runner.BaseTest;
+
+import java.time.Duration;
+
+@Ignore
+public class WithoutGroupTest extends BaseTest {
+
+ @Test
+ public void testLogin() {
+ WebDriver driver = getDriver();
+ driver.get("https://www.saucedemo.com/");
+
+ driver.findElement(By.xpath("//input[@id='user-name']")).sendKeys("standard_user");
+ driver.findElement(By.xpath("//input[@id='password']")).sendKeys("secret_sauce");
+ driver.findElement(By.xpath("//*[@id='login-button']")).click();
+
+ Assert.assertEquals(driver.getCurrentUrl(), "https://www.saucedemo.com/inventory.html",
+ "Url does not match expected");
+
+ Assert.assertEquals(driver.findElements(By.xpath("//div[@class='inventory_item']")).size(), 6,
+ "Count of cards is not as expected");
+ }
+
+ @Test
+ public void testTextBox() throws InterruptedException {
+ WebDriver driver = getDriver();
+ driver.get("https://demoqa.com");
+ driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
+
+ driver.findElement(By.cssSelector(".card:nth-child(1)")).click();
+ driver.findElement(By.cssSelector(".btn-light:nth-child(1)")).click();
+
+ driver.findElement(By.id("userName")).sendKeys("Lilia");
+ driver.findElement(By.id("userEmail")).sendKeys("test@gmail.com");
+
+ WebElement footer = driver.findElement(By.tagName("footer"));
+ int deltaY = footer.getRect().y;
+ new Actions(driver)
+ .scrollByAmount(0, deltaY)
+ .perform();
+
+ Thread.sleep(1000);
+
+ driver.findElement(By.className("text-right")).click();
+
+ Assert.assertEquals(driver.findElement(By.id("name")).getText(), "Name:Lilia");
+ Assert.assertEquals(driver.findElement(By.id("email")).getText(), "Email:test@gmail.com");
+ }
+
+ @Test
+ public void TestAliceAndCat() {
+ getDriver().get("https://aliceandcat.ru/");
+ WebElement harryPotterButton = getDriver().findElement(By.id("menu-item-1590"));
+ harryPotterButton.click();
+ WebElement wizardingBooksBuy = getDriver().findElement(By.xpath("//*[@data-productid='1460']"));
+ wizardingBooksBuy.click();
+ WebElement checkoutForm = getDriver().findElement(By.className("woocommerce"));
+ Assert.assertNotNull(checkoutForm, "Element Checkout Form is not found");
+ }
+}
diff --git a/src/test/java/school/redrover/runner/BaseTest.java b/src/test/java/school/redrover/runner/BaseTest.java
new file mode 100644
index 0000000..6616f5a
--- /dev/null
+++ b/src/test/java/school/redrover/runner/BaseTest.java
@@ -0,0 +1,79 @@
+package school.redrover.runner;
+
+import org.openqa.selenium.WebDriver;
+import org.testng.ITestResult;
+import org.testng.annotations.*;
+
+import java.lang.reflect.Method;
+
+@Listeners({FilterForTests.class})
+public abstract class BaseTest {
+
+ private WebDriver driver;
+
+ private void startDriver() {
+ ProjectUtils.log("Browser open");
+
+ driver = ProjectUtils.createDriver();
+ }
+
+ private void clearData() {
+ ProjectUtils.log("Clear data");
+ JenkinsUtils.clearData();
+ }
+
+ private void loginWeb() {
+ ProjectUtils.log("Login");
+ JenkinsUtils.login(driver);
+ }
+
+ private void getWeb() {
+ ProjectUtils.log("Get web page");
+ ProjectUtils.get(driver);
+ }
+
+ private void stopDriver() {
+ try {
+ JenkinsUtils.logout(driver);
+ } catch (Exception ignore) {}
+
+ closeDriver();
+ }
+
+ private void closeDriver() {
+ if (driver != null) {
+ driver.quit();
+
+ driver = null;
+
+ ProjectUtils.log("Browser closed");
+ }
+ }
+
+ @BeforeMethod
+ protected void beforeMethod(Method method) {
+ ProjectUtils.logf("Run %s.%s", this.getClass().getName(), method.getName());
+ try {
+ clearData();
+ startDriver();
+ getWeb();
+ loginWeb();
+ } catch (Exception e) {
+ closeDriver();
+ throw new RuntimeException(e);
+ }
+ }
+
+ @AfterMethod
+ protected void afterMethod(Method method, ITestResult testResult) {
+ if (testResult.isSuccess() || ProjectUtils.closeBrowserIfError()) {
+ stopDriver();
+ }
+
+ ProjectUtils.logf("Execution time is %o sec\n\n", (testResult.getEndMillis() - testResult.getStartMillis()) / 1000);
+ }
+
+ protected WebDriver getDriver() {
+ return driver;
+ }
+}
diff --git a/src/test/java/school/redrover/runner/FilterForTests.java b/src/test/java/school/redrover/runner/FilterForTests.java
new file mode 100644
index 0000000..281166d
--- /dev/null
+++ b/src/test/java/school/redrover/runner/FilterForTests.java
@@ -0,0 +1,32 @@
+package school.redrover.runner;
+
+import org.testng.*;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public class FilterForTests implements IMethodInterceptor {
+
+ @Override
+ public List intercept(List methods, ITestContext context) {
+
+ String files = System.getenv("LIST_OF_CHANGED_FILES");
+ if (files != null) {
+ Set fileSet = new HashSet<>(Arrays.asList(files.split(";")));
+ Map, String> classMap = methods.stream()
+ .map(IMethodInstance::getMethod).map(ITestNGMethod::getTestClass).map(IClass::getRealClass)
+ .collect(Collectors.toMap(
+ Function.identity(),
+ clazz -> String.format("src/test/java/%s.java", clazz.getName().replace('.', '/')),
+ (pathA, pathB) -> pathA
+ ));
+
+ if (classMap.values().containsAll(fileSet)) {
+ return methods.stream().filter(method -> fileSet.contains(classMap.get(method.getMethod().getTestClass().getRealClass()))).collect(Collectors.toList());
+ }
+ }
+
+ return methods;
+ }
+}
diff --git a/src/test/java/school/redrover/runner/JenkinsUtils.java b/src/test/java/school/redrover/runner/JenkinsUtils.java
new file mode 100644
index 0000000..cfc0f5e
--- /dev/null
+++ b/src/test/java/school/redrover/runner/JenkinsUtils.java
@@ -0,0 +1,201 @@
+package school.redrover.runner;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+
+import java.net.URI;
+import java.net.URLEncoder;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class JenkinsUtils {
+
+ private static final HttpClient client = HttpClient.newBuilder().build();
+
+ private static String sessionId;
+
+ private static String getCrumbFromPage(String page) {
+ final String CRUMB_TAG = "data-crumb-value=\"";
+
+ int crumbTagBeginIndex = page.indexOf(CRUMB_TAG) + CRUMB_TAG.length();
+ int crumbTagEndIndex = page.indexOf('"', crumbTagBeginIndex);
+
+ return page.substring(crumbTagBeginIndex, crumbTagEndIndex);
+ }
+
+ private static Set getSubstringsFromPage(String page, String from, String to) {
+ // 255 - максимально возможная длинна имени, но если используется не латиница или специальные символы, страка будет длинней из-за кодирования (пробел - %20)
+ return getSubstringsFromPage(page, from, to, 256);
+ }
+
+ private static Set getSubstringsFromPage(String page, String from, String to, int maxSubstringLength) {
+ Set result = new HashSet<>();
+
+ int index = page.indexOf(from);
+ while (index != -1) {
+ index += from.length();
+ int endIndex = page.indexOf(to, index);
+
+ if (endIndex != -1 && endIndex - index < maxSubstringLength) {
+ result.add(page.substring(index, endIndex));
+ } else {
+ endIndex = index;
+ }
+
+ index = page.indexOf(from, endIndex);
+ }
+
+ return result;
+ }
+
+ private static String[] getHeader() {
+ List result = new ArrayList<>(List.of("Content-Type", "application/x-www-form-urlencoded"));
+ if (sessionId != null) {
+ result.add("Cookie");
+ result.add(sessionId);
+ }
+ return result.toArray(String[]::new);
+ }
+
+ private static HttpResponse getHttp(String url) {
+ try {
+ return client.send(
+ HttpRequest.newBuilder()
+ .uri(URI.create(url))
+ .headers(getHeader())
+ .GET()
+ .build(),
+ HttpResponse.BodyHandlers.ofString());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static HttpResponse postHttp(String url, String body) {
+ try {
+ return client.send(
+ HttpRequest.newBuilder()
+ .uri(URI.create(url))
+ .headers(getHeader())
+ .POST(HttpRequest.BodyPublishers.ofString(body))
+ .build(),
+ HttpResponse.BodyHandlers.ofString());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String getPage(String uri) {
+ HttpResponse page = getHttp(ProjectUtils.getUrl() + uri);
+ if (page.statusCode() != 200) {
+ final String HEAD_COOKIE = "set-cookie";
+
+ HttpResponse loginPage = getHttp(ProjectUtils.getUrl() + "login?from=%2F");
+ sessionId = loginPage.headers().firstValue(HEAD_COOKIE).orElse(null);
+
+ // Поле sessionId используется внутри postHttp
+ HttpResponse indexPage = postHttp(ProjectUtils.getUrl() + "j_spring_security_check",
+ String.format("j_username=%s&j_password=%s&from=%%2F&Submit=",
+ URLEncoder.encode(ProjectUtils.getUserName(), StandardCharsets.UTF_8),
+ URLEncoder.encode(ProjectUtils.getPassword(), StandardCharsets.UTF_8)));
+ sessionId = indexPage.headers().firstValue(HEAD_COOKIE).orElse("");
+
+ page = getHttp(ProjectUtils.getUrl() + uri);
+ }
+
+ if (page.statusCode() == 403) {
+ throw new RuntimeException(String.format("Authorization does not work with user: \"%s\" and password: \"%s\"", ProjectUtils.getUserName(), ProjectUtils.getPassword()));
+ } else if (page.statusCode() != 200) {
+ throw new RuntimeException("Something went wrong while clearing data");
+ }
+
+ return page.body();
+ }
+
+ private static void deleteByLink(String link, Set names, String crumb) {
+ String fullCrumb = String.format("Jenkins-Crumb=%s", crumb);
+ for (String name : names) {
+ postHttp(String.format(ProjectUtils.getUrl() + link, name), fullCrumb);
+ }
+ }
+
+ private static void deleteJobs() {
+ String mainPage = getPage("");
+ deleteByLink("job/%s/doDelete",
+ getSubstringsFromPage(mainPage, "href=\"job/", "/\""),
+ getCrumbFromPage(mainPage));
+ }
+
+ private static void deleteViews() {
+ String mainPage = getPage("");
+ deleteByLink("view/%s/doDelete",
+ getSubstringsFromPage(mainPage, "href=\"/view/", "/\""),
+ getCrumbFromPage(mainPage));
+
+ String viewPage = getPage("me/my-views/view/all/");
+ deleteByLink("user/admin/my-views/view/%s/doDelete",
+ getSubstringsFromPage(viewPage, "href=\"/user/admin/my-views/view/", "/\""),
+ getCrumbFromPage(viewPage));
+ }
+
+ private static void deleteUsers() {
+ String userPage = getPage("manage/securityRealm/");
+ deleteByLink("manage/securityRealm/user/%s/doDelete",
+ getSubstringsFromPage(userPage, "href=\"user/", "/\"").stream()
+ .filter(user -> !user.equals(ProjectUtils.getUserName())).collect(Collectors.toSet()),
+ getCrumbFromPage(userPage));
+ }
+
+ private static void deleteNodes() {
+ String mainPage = getPage("");
+ deleteByLink("manage/computer/%s/doDelete",
+ getSubstringsFromPage(mainPage, "href=\"/computer/", "/\""),
+ getCrumbFromPage(mainPage));
+ }
+
+ private static void deleteDescription() {
+ String mainPage = getPage("");
+ postHttp(ProjectUtils.getUrl() + "submitDescription",
+ String.format(
+ "description=&Submit=&Jenkins-Crumb=%1$s&json=%%7B%%22description%%22%%3A+%%22%%22%%2C+%%22Submit%%22%%3A+%%22%%22%%2C+%%22Jenkins-Crumb%%22%%3A+%%22%1$s%%22%%7D",
+ getCrumbFromPage(mainPage)));
+ }
+
+ private static void deleteCredentials() {
+ String mainPage = getPage("");
+ postHttp(ProjectUtils.getUrl() + "manage/credentials/store/system/domain/_/doDelete",
+ String.format("Jenkins-Crumb=%s", getCrumbFromPage(mainPage)));
+
+ postHttp(ProjectUtils.getUrl() + "user/admin/credentials/store/user/domain/_/doDelete",
+ String.format("Jenkins-Crumb=%s", getCrumbFromPage(mainPage)));
+ }
+
+ static void clearData() {
+ JenkinsUtils.deleteViews();
+ JenkinsUtils.deleteJobs();
+ JenkinsUtils.deleteUsers();
+ JenkinsUtils.deleteNodes();
+ JenkinsUtils.deleteDescription();
+ JenkinsUtils.deleteCredentials();
+ }
+
+ static void login(WebDriver driver) {
+ driver.findElement(By.name("j_username")).sendKeys(ProjectUtils.getUserName());
+ driver.findElement(By.name("j_password")).sendKeys(ProjectUtils.getPassword());
+ driver.findElement(By.name("Submit")).click();
+ }
+
+ static void logout(WebDriver driver) {
+ ProjectUtils.get(driver);
+
+ driver.findElement(By.xpath("//a[@href='/logout']")).click();
+ }
+}
+
diff --git a/src/test/java/school/redrover/runner/ProjectUtils.java b/src/test/java/school/redrover/runner/ProjectUtils.java
new file mode 100644
index 0000000..99556d9
--- /dev/null
+++ b/src/test/java/school/redrover/runner/ProjectUtils.java
@@ -0,0 +1,121 @@
+package school.redrover.runner;
+
+import org.openqa.selenium.Alert;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Duration;
+import java.util.Properties;
+
+
+public final class ProjectUtils {
+
+ private static final String PREFIX_PROP = "local.";
+ private static final String PROP_HOST = PREFIX_PROP + "host";
+ private static final String PROP_PORT = PREFIX_PROP + "port";
+ private static final String PROP_ADMIN_USERNAME = PREFIX_PROP + "admin.username";
+ private static final String PROP_ADMIN_PAS = PREFIX_PROP + "admin.password";
+
+ private static final String CLOSE_BROWSER_IF_ERROR = PREFIX_PROP + "closeBrowserIfError";
+
+ private static final String ENV_CHROME_OPTIONS = "CHROME_OPTIONS";
+ private static final String ENV_APP_OPTIONS = "APP_OPTIONS";
+
+ private static final String PROP_CHROME_OPTIONS = PREFIX_PROP + ENV_CHROME_OPTIONS.toLowerCase();
+
+ private static Properties properties;
+
+ private static void initProperties() {
+ if (properties == null) {
+ properties = new Properties();
+ if (isServerRun()) {
+ properties.setProperty(PROP_CHROME_OPTIONS, System.getenv(ENV_CHROME_OPTIONS));
+
+ if (System.getenv(ENV_APP_OPTIONS) != null) {
+ for (String option : System.getenv(ENV_APP_OPTIONS).split(";")) {
+ String[] optionArr = option.split("=");
+ properties.setProperty(PREFIX_PROP + optionArr[0], optionArr[1]);
+ }
+ }
+ } else {
+ try {
+ InputStream inputStream = ProjectUtils.class.getClassLoader().getResourceAsStream("local.properties");
+ if (inputStream == null) {
+ System.out.println("ERROR: The \u001B[31mlocal.properties\u001B[0m file not found in src/test/resources/ directory.");
+ System.out.println("You need to create it from local.properties.TEMPLATE file.");
+ System.exit(1);
+ }
+ properties.load(inputStream);
+ } catch (IOException ignore) {
+ }
+ }
+ }
+ }
+
+ static final ChromeOptions chromeOptions;
+
+ static {
+ initProperties();
+
+ chromeOptions = new ChromeOptions();
+ String options = properties.getProperty(PROP_CHROME_OPTIONS);
+ if (options != null) {
+ for (String argument : options.split(";")) {
+ chromeOptions.addArguments(argument);
+ }
+ }
+ }
+
+ static boolean isServerRun() {
+ return System.getenv("CI_RUN") != null;
+ }
+
+ static boolean closeBrowserIfError() {
+ return Boolean.parseBoolean(properties.getProperty(CLOSE_BROWSER_IF_ERROR, "true"));
+ }
+
+ static String getUrl() {
+ return String.format("http://%s:%s/",
+ properties.getProperty(PROP_HOST),
+ properties.getProperty(PROP_PORT));
+ }
+
+ static String getUserName() {
+ return properties.getProperty(PROP_ADMIN_USERNAME);
+ }
+
+ static String getPassword() {
+ return properties.getProperty(PROP_ADMIN_PAS);
+ }
+
+ static void acceptAlert(WebDriver driver) {
+ Alert alert = ExpectedConditions.alertIsPresent().apply(driver);
+ if (alert != null) {
+ alert.accept();
+ }
+ }
+
+ static WebDriver createDriver() {
+ WebDriver driver = new ChromeDriver(ProjectUtils.chromeOptions);
+ driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
+
+ return driver;
+ }
+
+ public static void get(WebDriver driver) {
+ driver.get(getUrl());
+ }
+
+ public static void log(String str) {
+ System.out.println(str);
+ }
+
+ public static void logf(String str, Object... arr) {
+ System.out.printf(str, arr);
+ System.out.println();
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/local.properties.TEMPLATE b/src/test/resources/local.properties.TEMPLATE
new file mode 100644
index 0000000..7032d52
--- /dev/null
+++ b/src/test/resources/local.properties.TEMPLATE
@@ -0,0 +1,6 @@
+local.admin.username=<>
+local.admin.password=<>
+local.host=localhost
+local.port=8080
+local.chrome_options=--window-size=1920,1080
+local.closeBrowserIfError=false