7

Is there is any way to highlight the validation message by using Selenium IDE?

Example: During login when the user passes the invalid input the validation messages and login will be failed. I want to highlight the validation message which is getting displayed on the screen.

5
  • 1
    What do you mean with Highlight? Select the text with the mouse? Apr 29, 2019 at 12:29
  • @NielsvanReijmersdal - Please see my screenshot and help me - screencast.com/t/MUa5kqLI5 Apr 29, 2019 at 12:34
  • I still do not understand what you want to do. Apr 29, 2019 at 12:36
  • do you want to make a screenshot of the page and apply a visual highlight? or do you for example want the error text in your log? like throw new RuntimeExeption("error text") would do? Apr 29, 2019 at 12:49
  • @globalworming,- Yes I want to apply the visual highlight basically highlighting the element feature like below screenshot - screencast.com/t/QKMJxhQefn8 Apr 29, 2019 at 13:09

3 Answers 3

4

You can use the "run script" command with JavaScript code in the target field.

Here some example code to highlight the first h1 element on a page with XPath:

document.evaluate('//h1', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.setAttribute('style', 'outline: red dashed 5px !important')

I can't seem to pass found elements with Selenium IDE, so you need to locate in JavaScript code.

Looks something like this:

enter image description here

2

When looking at the API of selenium IDE there is no way to do it. https://sqa.stackexchange.com/a/38970/35888

If you have access to the webdriver you can visually highlight specific elements by playing around with the css dynamically. https://stackoverflow.com/questions/24882723/how-can-i-set-new-style-of-element-using-selenium-web-driver

JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(yourElement);
js.executeScript("arguments[0].setAttribute('style', 'outline: yellow dashed 5px !important')", element);

in your case you would want to set the background color of the element.

2
  • I got it working based on your idea to use the JavaScript Executor that is present in the new Selenium IDE :) Apr 29, 2019 at 14:24
  • oh, run script, didn't see that, nice Apr 29, 2019 at 14:34
0

I believe that was functionality provided by the old, different version of SelniumIDE before the complete re-write in 2018.

I no longer see that built-in functionality in the new SelenumIDE.

Your Answer

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

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