How To Handle Modal Or Pop-up Boxes In Selenium Python
I'm using selenium python to test a resturant pos system. After click different category menus,there will be about 3 different kinds of pop-up(modal) windows pop out to allow custo
Solution 1:
I think you can use get_attribute("style")
to accomplish what you are trying to do here. From what I can tell, you are not actually working with a true alert -- an alert is a Javascript popup that has no HTML, and can be only accepted or dismissed through the alerts class.
Here's how you can check the display: none
and display: block
strings in each element:
first_item = driver.find_element_by_id("iopopsz")
style_attr_first_item = first_item.get_attribute("style") # "display: none"
if "display: none;" in style_attr_first_item:
print("First item is not visible.")
Hopefully this will get you started and shows you how to effectively check the display: none
and display: block
properties of each element.
Post a Comment for "How To Handle Modal Or Pop-up Boxes In Selenium Python"