Reputation: 71
I am getting the values from a drop down as calOptions. The options printed in Output are as expected, but I am unable to assert the drop drown options with the list I have created: My_list = [All, Overdue] I need to verify if the drop down options are "All" and "Overdue". Please help.
my_list = ["All", "Overdue"]
global calOption
calOptions = driver.find_elements_by_xpath("//*/p-dropdownitem")
for calOption in calOptions:
print(calOption.text)
Assert calOption.text == my_list
**Output:**
All
Overdue
assert <selenium.webdriver.remote.webelement.WebElement (session="2a371065044a85d7da742d003742ce30",
element="58647425-0660-4dd4-aad9-9a517f40730e")> == ['All', 'Overdue']
======================Assertion Error
Upvotes: 0
Views: 939
Reputation: 4869
Try below code to compare expected and actual drop-down values:
my_list = ["All", "Overdue"]
cal_options = [element.text for element in driver.find_elements_by_xpath("//*/p-dropdownitem")]
assert my_list == cal_options
Upvotes: 1