My website has a search feature that displays a warning message when invalid data, such as special characters, is used in the search.
Upon loading the page, the CSS initially loads like this:
<div class="searchError" id="isearchError" style="display: none;">
When entering invalid text and hitting the search button, the above code changes to:
display: block; opacity: …;
and it also triggers the display of
<div class="marker"></div>
along with an error message.
I attempted using the following code snippet:
var styleValue = element(by.id('ideliveryareaerror')).getCssValue('style');
but ended up with a complex tree structure of the element.
Here's an example of my code:
var styleValue = element(by.id('isearchError')).getCssValue('style');
browser.actions().sendKeys(protractor.Key.ENTER).perform();
browser.sleep(1000);
console.log(styleValue);
browser.sleep(1000);
What I aim to achieve is:
- Retrieve the value of the style attribute (Expected to be none)
- Trigger enter key press with invalid input
- Retrieve the value of the style attribute (Expected to be block)
- Fetch the content of the error message
Screenshot of my code: https://i.sstatic.net/CpPIA.jpg