문제

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?

도움이 되었습니까?

해결책

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")>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top