Python, Asserting Text & WebDriver

Quick tutorial for help my friend, how to verify if looking text exist.
[code language="python"]
'''
Sources:
find_element_by*
in operator
comparison '!='
assertion
'''
driver = webdriver.Firefox()

mytext = driver.find_elements_by_id(“myID”).text
if “Selenium WebDriver” in mytext
print “I found my text!”
else:
.........

# or some more simple example:
if element.text != u'SomeText':
print "Verify Failed: element text is not " % element.text

# or ...
assertTrue(findElement(By.id("myID";)).getText().equals("foo")

Obviously "object" identifier can to be changed like: (CSS, XPATH, tagName, ... etc)
[/code]

Comments

Popular posts from this blog

Robot Framework vs Cucumber

Performance Testing of RESTful APIs Using JMeter

Verification displayed number of rows inside table by Robot Framework