1

How do you locate a error message that appears as a tooltip in the browser console? It disappears before I can inspect it. I was thinking the firstname field's error message would be this, but selenium cannot find it.

 static By firstnameerror = By.cssSelector
 ("div.row-fluid.first-name-container>div.errorMessageBox");     

 WebDriverWait wait = new WebDriverWait (webdriver, 60);
 wait.until(ExpectedConditions.elementToBeClickable(createacct));
 WebElement create_acct = webdriver.findElement(createacct);
 create_acct.click();

 WebElement iframeSwitch = webdriver.findElement(
 By.id("register-  iframe"));
 webdriver.switchTo().frame(iframeSwitch);
 wait.until(ExpectedConditions.elementToBeClickable(submit));
 WebElement submitbtn = webdriver.findElement(submit);
 submitbtn.click();

 String pleasefilloutthisfield = 
 webdriver.findElement(firstname).getText();
 log.info("FirstName error message: "+pleasefilloutthisfield);

enter image description here

3
  • You can try using a hybrid tool, such as TestComplete or Ranorex, they will help you locate it; having said it, even you can locate this tooltip with a hybrid tool, it does not mean you can find it using Selenium in a console.
    – Yu Zhang
    Commented Apr 5, 2018 at 22:40
  • Thanks. Are those free tools? Commented Apr 5, 2018 at 22:47
  • No, but you can download trial versions
    – Yu Zhang
    Commented Apr 5, 2018 at 22:48

2 Answers 2

1

I found the answer here.

You can't get the text, but the required attribute defaults to the standard text "please fill out this field", so you can check the required attribute.

 WebElement first_name = webdriver.findElement(firstname);

String pleasefilloutthisfield = first_name.getAttribute("required");

log.info("Got firstName error message: "+pleasefilloutthisfield);
0

open the URL in Chrome and as soon as your Element appears (the one that disappear quickly ) click F8 , this will stop DOM from running and you can loca

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.