I am trying understand why an if else
isn't working using Selenium and Python. I have tried several different variations, but I believe this should work and stubbornly, maybe blindly, keep coming back to it.
example:
if (self.driver.find_element_by_class_name('product')).text == "FEATURED PRODUCTS":
print "\nHome Pass"
else:
print "\nHome Fail"
Tried this as well
if self.driver.find_element_by_class_name("product-teaser-list").text in "Featured Products":
Each execution returns Fail
and when using assert, below, the .text
is found. So I know the text is found with this method.
assert "FEATURED PRODUCTS" in self.driver.find_element_by_class_name('product').text
try this following code.
if "FEATURED PRODUCTS" in self.driver.find_element_by_class_name('product').text
If this isn't working try to debug that. something white space creates an issue. however given the assert statement is passing, following should work.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments