From 993079bc6ee372204e1153f2088995888389e65a Mon Sep 17 00:00:00 2001 From: Arul Date: Thu, 7 Aug 2025 03:07:37 +0530 Subject: [PATCH] Automation code Refined to wait and click the Quests and reach Quests screen --- .../java/com/ghost/temple/hooks/Hooks.java | 9 +++++++- .../com/ghost/temple/pages/QuestCreator.java | 21 +++++++++++++++--- .../com/ghost/temple/hooks/Hooks.class | Bin 629 -> 861 bytes target/cucumber-report.html | 2 +- .../TEST-com.ghost.temple.AppTest.xml | 4 ++-- .../TEST-com.ghost.temple.TestRunner.xml | 4 ++-- .../com.ghost.temple.AppTest.txt | 2 +- .../com.ghost.temple.TestRunner.txt | 2 +- .../com/ghost/temple/pages/QuestCreator.class | Bin 999 -> 1584 bytes 9 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/ghost/temple/hooks/Hooks.java b/src/main/java/com/ghost/temple/hooks/Hooks.java index 10bd6da..c92f91d 100644 --- a/src/main/java/com/ghost/temple/hooks/Hooks.java +++ b/src/main/java/com/ghost/temple/hooks/Hooks.java @@ -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 } } diff --git a/src/test/java/com/ghost/temple/pages/QuestCreator.java b/src/test/java/com/ghost/temple/pages/QuestCreator.java index 2c2402e..d95ec3e 100644 --- a/src/test/java/com/ghost/temple/pages/QuestCreator.java +++ b/src/test/java/com/ghost/temple/pages/QuestCreator.java @@ -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); } } diff --git a/target/classes/com/ghost/temple/hooks/Hooks.class b/target/classes/com/ghost/temple/hooks/Hooks.class index d8d1fc9190dd6068e068b71f9cef3e0b4827d3eb..8c533062d21cf906ceddda221a72f07648c479a6 100644 GIT binary patch literal 861 zcmaJfgc5Ph3Cb!uGNrXfwC^aCg)Eno?8A_%Ea5JfIXG~~WpTa-j z+zUh;_yPPV#CQ`CRh8<)jK@3s=Dj!m^Y_-lxO1 z&`sVR2!>LqB0gwwEwg(1(J?(aV%P|;;?Q6yjD-1=Fsyw{V3LNsaNR%4#tXwej1ssqZ5a$)x;is$r_gGVtt1~pux z=ua9bFHpsBolbLDoOUhQKH!Nx1Dr9IXE+{pf>82wdxquw$EsYwTAgC`=~i~HR7Q1- zo8M6k_kLh&jGc4KWe)QsC~uioNDOrn&I;9KVz-KARPD6N1Z6tSgM%9Cgs^Mpl0UIH delta 344 zcmcc1_LW8a)W2Q(7#J9A8DzN_m>8JZ8CZB2SQ*$R>MQYbF>o+&vNLe;FmM9}erl*Q zGH_+)WtO-UWtOEDfn<4k82A|2fWn2PFkyBEfr-5G?2HU7&iN^+6O;NU8#Ag+mS>W! z=Leb(0?Z7IARBh+1$l%4=w@c1PK5qU7N`N@KuM7C5@5}e*bL)AH%tI%m>`m2 P=w?ZQ&5{O^ObjvrS|}gb diff --git a/target/cucumber-report.html b/target/cucumber-report.html index 7e27be3..f3eb51f 100644 --- a/target/cucumber-report.html +++ b/target/cucumber-report.html @@ -40,7 +40,7 @@ body{padding:0;margin:0}.html-formatter{max-width:1600px;min-height:100vh;margin