Question

I'm using web driver to automate a test case. I'm trying to verify the text present in the page or not. I'm doing the following, but I don't know how to verify the textPresent is what I'm actually looking for.

textPresent = driver.find_element_by_xpath ("//span/p")

then when I did textPresent.text it's giving the text "An error occured processing Order" where I'm actually looking for "Successfuly added to processing" in the same xpath location. So in this situation, I want to fail the test case. How do i do that?

Was it helpful?

Solution

We should include a check point to verify the equality of actual text with expected :

expectedText = "Successfuly added to processing";
textPresent = driver.find_element_by_xpath ("//span/p");

if textPresent != expectedText
   <Write fail condition here e.g. return "Fail" or raise Exception("Fail")>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top