0
public void verifySeleniumTitle()
{
    WebUI.openBrowser('https://www.google.com')
    driver = DriverFactory.getWebDriver();
    driver.manage().window().maximize();
    
    driver.get("https://www.google.com");
    
    // Specify implicit wait of 30 seconds
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    
    // No text is present on Webpage.
    driver.findElement(By.xpath("//*[text()=\"Hello World\"]"));
    }
}

Crating a new custom keyword for my test case in katalon studio, and I am creating implicit wait, the code above enables me to receive a NoSuchElement Exception Message but I do not know if the time stated in implicit wait is totally working. Can someone help me figure this out? Thank you very much!

Prophet
  • 32,350
  • 22
  • 54
  • 79

1 Answers1

0

Just see if the NoSuchElement Exception thrown immediately after opening the "https://www.google.com" URL or it waits 30 seconds as defined in your implicitlyWait and only after the 30 seconds timeout the exception is thrown.

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • Thanks for answering, but I just wanted to know if is there any other way like for example throwing the 30 seconds time in console. Because upon reading the error message it states 'timeouts: {implicit: 0, pageLoad: 300000, script: 30000},'. So im wondering if the implicitwait did not work. – John Paul Arcilla May 28 '21 at 07:05
  • Looks like `implicitlyWait` didn't catch. Try putting `driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);` before `driver.get("https://www.google.com");`. Does it change the result? – Prophet May 28 '21 at 07:19
  • I did what you said and tried to change the 30 seconds to 120 and the NoSuchElement Exception took a while to appear. But this is still in the error message 'timeouts: {implicit: 0, pageLoad: 300000, script: 30000},' So I'm still confused if it is working or not? Thank you very much for answering my question! – John Paul Arcilla May 28 '21 at 07:30
  • Try this answer https://stackoverflow.com/questions/54026119/is-there-a-way-to-set-implicit-timeouts-beyond-the-driver-manage-timeouts-me. If this doesn't help will try to think about something else – Prophet May 28 '21 at 07:56
  • Hi Prophet, I tried to modified my keyword and tried to use it before clicking a button and it actually works. It waited for 2min before clicking a button and I tried to disabled it and the button was clicked right away does it mean it works?. If yes, I dont know how to prove it, my idea is probably print a message in console. – John Paul Arcilla May 28 '21 at 08:29
  • I think yes, it does. Unless you intended to get some other behavior / answer – Prophet May 28 '21 at 08:33
  • Thank you Prophet. One last question do you have an idea or can you give me some links or documentation regarding on how to change `driver.findElement(By.xpath("//*[text()=\"Hello World\"]"));` the xpath on this code dynamically. Thank you – John Paul Arcilla May 28 '21 at 08:58
  • Do you mean making this a method that receives xpath locator parameter finds and returns an element according to it? – Prophet May 28 '21 at 09:02
  • Yes sir `driver.findElement(By.xpath("//*[contains(text(),'"+ ProjectName +"')]")).click();`I tried using this code but it is not working, cause I tried to add this custom keywoard on my test case and it cannot have an input value. thank you – John Paul Arcilla May 28 '21 at 09:10
  • OK, since this is a new, separate question please first accept my answer here and then ask a new, separated question and I will try to answer you there – Prophet May 28 '21 at 09:17
  • I already posted a new question. Thank you for helping me out @Prophet – John Paul Arcilla May 28 '21 at 09:23
  • 1
    Ok I got it now I already accepted your answer. Thank you sir – John Paul Arcilla May 28 '21 at 09:27