我试图验证一些文本,例如“test001”在一个网页上使用驱动程序.getPageSource在Python中,Webdriver。 我得到错误对象没有属性“getPageSource”:
Traceback (most recent call last):
File "C:\Users\riaz.ladhani\PycharmProjects\Selenium Webdriver\ClearCore \TestCases\AdministrationPage_TestCase.py", line 32, in test_add_Project
administration_page.add_project()
File "C:\Users\riaz.ladhani\PycharmProjects\Selenium Webdriver\ClearCore \Pages\admin.py", line 43, in add_project
test = self.driver.getPageSource
AttributeError: 'WebDriver' object has no attribute 'getPageSource'
看了别人的帖子有类似的问题。他们的回答是使用getPageSource。 我不知道为什么会出错。谢谢你的帮助,谢谢。在
我的代码片段是:
^{pr2}$
对我来说似乎是个语法错误,应该是}。参见doc
page_source
而不是{试试看
然而,我认为,获取完整的页面源代码来测试一个单个的文本并不是一个好主意。只需找到所需的元素并测试元素是否包含您要查找的文本
相关问题 更多 >
编程相关推荐