RE: Pulling text from DIV element using Selenium/Java


The text is contained in a DIV element:
<div class=”messageText”>No matches found</div>

The CSS path is:
//#searchResultsWarningMessageBox > table > tbody > tr > td.messageCell > div

The code I have is:
WebElement txtMsg = driver.findElement(By.cssSelector(“#searchResultsWarningMessageBox > table > tbody > tr > td.messageCell > div”));

I keep gettingĀ  .. no such element. Any ideas or hints?

Richard Allen Train Asked on September 24, 2014 in Selenium WebDriver.
Add Comment
3 Answers

<div class=”searchResultsMessageContainer”>
<div class=”message warningM4″ id=”searchResultsWarningMessageBox”><table class=”messageTable” border=”0″ cellpadding=”0″ cellspacing=”0″><tbody><tr><td><img src=”/s.gif” alt=”Warning” class=”msgIcon” title=”Warning”></td><td class=”messageCell”><div class=”messageText”>No matches found</div></td></tr>
</tbody></table></div><script>if (window.sfdcPage) sfdcPage.registerMessage(‘searchResultsWarningMessageBox’);</script></div>

Train Answered on September 24, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.