- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试验证一些文本,例如在 Python、Webdriver 中使用 driver.getPageSource 的网页上的“test001”。我收到错误对象没有属性“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。我不确定为什么会收到错误消息。感谢一些帮助,谢谢。
我的代码片段是:
class AdministrationPage(BasePage):
def is_project_text_present(self, text):
#return str(text) in self.driver.getPageSource
try:
project_list_test = self.driver.getPageSource
except NoSuchElementException, e:
return False
return "test001" in text # check if the project title text test001 is in the page, return true if it is
class AdministrationPage_TestCase(unittest.TestCase):
try: administration_page.is_text_present("test001")
except AssertionError as e: self.verificationErrors.append(str(e))
最佳答案
对我来说似乎是一个语法错误,它应该是 page_source
而不是 getPageSource
。查看doc
尝试
def is_project_text_present(self, text):
#return str(text) in self.driver.page_source
try:
project_list_test = self.driver.page_source
except NoSuchElementException, e:
return False
return "test001" in text # check if the project title text test001 is in the page, return true if it is
但是,我认为获取整页源代码来测试单个 文本并不是一个好主意。只需找到预期的元素并测试该元素是否包含您要查找的文本即可
关于python - 使用 getPageSource 检查网页上是否存在某些文本。我得到错误对象没有属性 getPageSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30330594/
我正在尝试验证一些文本,例如在 Python、Webdriver 中使用 driver.getPageSource 的网页上的“test001”。我收到错误对象没有属性“getPageSource”:
我需要程序中给出的url的来源。但是程序只返回一些 json 数据而不是整个页面源。有什么问题?? public class selenium { public static void main(St
我正在使用此功能登录页面: public static void login() { driver.get(url); driver.findElement(By.name("userna
我正在尝试编写一段代码,用户在其中输入Python,然后按回车键,这个应用程序“Python教程教程点”位于第四页。我的逻辑是:使用 getPageSource 找到该项目并继续单击“下一步”按钮。然
我正在使用 WebDriver 和 java 来获取页面源。使用 FirefoxDriver 我试图验证页面源上的一些文本,但是当我使用 driver.getPageSource 时,它会将一些符
下面这段代码的完整含义是什么?我的意思是,哪个对象实现哪个类并使用哪个方法? driver.getPageSource().contains("Text to find"); 最佳答案 让我们一个接一
我正在尝试使用 selenium 获取页面源 String ps = driver.getPageSource(); 但是页面源里面的链接是相对的,比如 因此我无法使用此源代码,因为图像/css 未
我正在尝试使用 selenium 将指定 URL 中的源代码捕获到 HTML 文件中,但我不知道为什么,我没有获得我们从浏览器中看到的确切源代码。 下面是我在 HTML 文件中捕获源代码的 java
我是 Selenium 的新手,想知道是否有人可以指出正确的方向。 我正在尝试获取页面的页面源,但我注意到 IE 驱动程序返回了一些东西不同于 FirefoxDriver。 此外,InternetEx
在使用 selenium 时,刚才我在解析 selenium getPageSource() 方法的输出时遇到错误。firefox页面源实际的meta标签= 使用带有 selenium = 的
当我尝试显示页面的源代码时, res.json 返回空白。 Selenium 日志显示已检索到源代码。知道如何正确接收更新的页面源吗? 如果我使用其他函数(例如获取当前网址),它会返回相同的结果。 代
我正在抓取一些网页,我注意到 rvest(read_html,然后 html_text)提供的结果与 RSelenium(getPageSource())提供的结果不同。 更具体地说,当涉及下拉菜单时
如何使用 Selenium WebDriver 和 Java 查看“title”和“meta”标签之间的页面源代码? 最佳答案 加载页面后,您可以尝试 driver.getPageSource()。
如何使用带有 Java 的 Selenium WebDriver 查看“title”和“meta”标签之间的页面源代码? 最佳答案 您可以在加载页面后尝试 driver.getPageSource()
我是一名优秀的程序员,十分优秀!