Selenium and xpath: finding a div with a class/id and verifying text inside

The Solution to Selenium and xpath: finding a div with a class/id and verifying text inside is


To verify this:-

<div class="Caption">
  Model saved
</div>

Write this -

//div[contains(@class, 'Caption') and text()='Model saved']

And to verify this:-

<div id="alertLabel" class="gwt-HTML sfnStandardLeftMargin sfnStandardRightMargin sfnStandardTopMargin">
  Save to server successful
</div>

Write this -

//div[@id='alertLabel' and text()='Save to server successful']

~ Answered on 2013-09-02 10:20:24


Most Viewed Questions: