Automation code Refined to wait and click the Quests and reach Quests screen

This commit is contained in:
Arul 2025-08-07 03:07:37 +05:30
parent fd224878d5
commit 993079bc6e
9 changed files with 33 additions and 11 deletions

View File

@ -13,6 +13,13 @@ public class Hooks {
@After
public void tearDown() {
DriverManager.quitDriver();
try {
// Wait for 15 seconds (15000 milliseconds)
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
DriverManager.quitDriver(); // Then quit driver
}
}

View File

@ -3,19 +3,34 @@ package com.ghost.temple.pages;
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 com.ghost.temple.ReusableFunctions;
import java.time.Duration;
public class QuestCreator {
WebDriver driver;
private By addQuestBtnLocator = By.xpath("//a[@href='/equipment']/button[contains(text(),'View All')]");
private By addQuestBtnLocator = By.xpath("//a[@href='/quests']/button[contains(text(),'View All')]");
public QuestCreator(WebDriver driver) {
this.driver = driver;
}
public void clickAddQuest() {
WebElement addQuestBtn = driver.findElement(addQuestBtnLocator);
addQuestBtn.click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
// Wait for the element to be clickable
WebElement addQuestBtn = wait.until(ExpectedConditions.elementToBeClickable(addQuestBtnLocator));
// Scroll into view using your reusable method
ReusableFunctions.scrollIntoView(driver, addQuestBtn);
// Use your reusable click
ReusableFunctions.click(addQuestBtn);
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="com.ghost.temple.AppTest" time="0" errors="0" skipped="0">
<testsuite tests="1" failures="0" name="com.ghost.temple.AppTest" time="0.001" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="17.0.15+6-Debian-1deb12u1"/>
@ -58,5 +58,5 @@
<property name="sun.cpu.endian" value="little"/>
<property name="sun.stdout.encoding" value="UTF-8"/>
</properties>
<testcase classname="com.ghost.temple.AppTest" name="basicTest" time="0"/>
<testcase classname="com.ghost.temple.AppTest" name="basicTest" time="0.001"/>
</testsuite>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="com.ghost.temple.TestRunner" time="11.29" errors="0" skipped="0">
<testsuite tests="1" failures="0" name="com.ghost.temple.TestRunner" time="24.783" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="17.0.15+6-Debian-1deb12u1"/>
@ -58,5 +58,5 @@
<property name="sun.cpu.endian" value="little"/>
<property name="sun.stdout.encoding" value="UTF-8"/>
</properties>
<testcase classname="Solo Leveling Quest Management" name="Open Solo Leveling page and click Add Quest" time="11.29"/>
<testcase classname="Solo Leveling Quest Management" name="Open Solo Leveling page and click Add Quest" time="24.783"/>
</testsuite>

View File

@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: com.ghost.temple.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec

View File

@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: com.ghost.temple.TestRunner
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.695 sec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 25.292 sec