我对自动化,公平警告非常陌生。 我有一个自动化脚本来验证页面的规范标签是否存在。我还需要断言它全是小写的。我会在“driver.find_element ...”之后创建一个断言来断言islower()吗?
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import unittest
class homepage_canonical(unittest.TestCase):
def setUp(self):
global driver
driver = webdriver.Firefox()
driver.get("websiteurlhere")
def test_hpcanonical(self):
WebDriverWait(driver, 10)
driver.find_element_by_css_selector("link[href='canonicalurlhere'][rel='canonical']")
def tearDown(self):
driver.quit()
if __name__ == "__main__":
unittest.main()
答案 0 :(得分:0)
我会使用assertTrue
:
def test_hpcanonical(self):
wait = WebDriverWait(driver, 10)
element = driver.find_element_by_css_selector("link[href='canonicalurlhere'][rel='canonical']")
self.assertTrue(element.text.islower())