Python Selenium:在元素列表中断言文本

Python Selenium:在元素列表中断言文本,python,selenium,xpath,pageobjects,Python,Selenium,Xpath,Pageobjects,我试图介绍一种情况,在这种情况下,我需要查看div列表中是否不存在字符串。XPATH表达式返回N个div,其中包含我需要断言的文本。也许你们能帮我弄清楚?你可以在下面找到我的代码 定位器: 定位器 lines_all = (By.XPATH, '/html/body/div[1]/div[3]/div/div[3]/div[1]/div[1]/div[2]/div[8]/div/div[1]') 功能:number_page.py def check_dem_lines(self):

我试图介绍一种情况,在这种情况下,我需要查看div列表中是否不存在字符串。XPATH表达式返回N个div,其中包含我需要断言的文本。也许你们能帮我弄清楚?你可以在下面找到我的代码

定位器: 定位器

lines_all = (By.XPATH, '/html/body/div[1]/div[3]/div/div[3]/div[1]/div[1]/div[2]/div[8]/div/div[1]')
功能:number_page.py

def check_dem_lines(self):
    lines = self.driver.find_elements(*Locators.lines_all)
    return lines
测试:tests.py

def test_lines(self):
    main_page.find_number(number)
    number_lines = number_page.check_dem_lines()
    for lines in number_lines:
        if lines.text == 'String that should not be there':
            assert False

你有什么问题。如果有错误,请提供相同的堆栈。请在你的问题中添加信息你遇到了什么问题。如果有错误,请提供相同的堆栈。请在您的问题中添加信息