- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一些 Selenium 代码,可以使用以下代码将各种搜索词输入到网站的搜索字段中:
browser = webdriver.Chrome()
browser.get(url)
search_box1 = browser.find_element_by_id('searchText-0')
search_box2 = browser.find_element_by_id('searchText-2-dateInput')
search_box1.send_keys("Foobars")
search_box1.send_keys("2013")
search_box1.submit()
然后我编写了更多代码来获取给定搜索查询结果的点击次数。然而,对于特定年份的“Foobars”的某些值,没有命中,查询结果如下所示:
<body class="search">
<div id="skip">...</div>
<div style = "display:non;">...</div>
<div id="container" class="js">
<div id="header">...</div>
<div id="search">...</div>
<div id="helpContent">...</div>
<div id="main-body" class="noBg">
<div class="error">
<div>Sorry. There are no articles that contain all the keywords you entered.</div>
<p>Possible reasons:
</p>
<ul></ul>
<p></p>
<p></p>
</div>
</div>
当搜索查询命中时,如何检查搜索查询是这个而不是我得到的页面?我打算实现一个 if 语句来检查搜索查询是否返回了某些内容,但我似乎无法找出正确的语法来获取我需要执行此操作的错误元素。我尝试过这样的事情:
Error=browser.find_element_by_name('error')
或
Error=browser.find_element_by_xpath("//div[@class='error']")
但我不断收到错误:
selenium.common.exceptions.NoSuchElementException: Message: u'no such element\n
我想识别错误元素,以便我可以执行类似的操作
if Error == "There are no articles that contain all the keywords you entered":
do something
else:
do something else
或者更好的是,可以告诉我是否存在用于条件的错误。任何帮助将不胜感激。
最佳答案
也许你来得太快了?尝试一下
from selenium.webdriver.support import expected_conditions as EC
....
Error= WebDriverWait(ff, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='error']")))
关于python - 使用 Python 在 .submit() 之后搜索 Selenium 中的错误元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20282201/
我创建了一个函数来在两个元素的 style.display 之间切换为“none”或“block”。我在这里遇到的问题是“发送”按钮似乎与“切换”按钮具有相同的行为。这不是我指定它要做的事情。我想知道
当我使用 validate.js 添加表单验证时,其验证正常并显示验证消息。但输入 type="submit"值在操作页面结构中显示两次。 为了说明,我有两个 .cfm 文件,index.cfm 具有
我有一个 s:form,里面有 sj:submit 和 s:submit,sj:submit 工作正常,但 s:submit 按钮不起作用。当我点击 s:submit 按钮时没有任何反应。 我尝试在表
参见http://jsfiddle.net/8KNc7/5/有关我正在讨论的内容的工作示例(目前在 Firefox 15 中进行测试,尚未尝试其他版本)。 我有一个带有 submit 输入和 butt
我有一个包含表单的 HTML 页面。我想做一些字段 "required" 。问题是我没有使用 在我的表单中,我使用 Javascript 函数来提交表单,因为我需要将 Javascript 变量发送到
如果用户提交表单,我想运行特定的 PHP block 。如果我使用带有 name="submit"的提交按钮并且: 我对 javascript 一无所知,我希望代码在用户更改下拉菜单时运行。如果我将
我有一个网站 www.abc.com,其中有一个页面 xyz.php。 xyz.php 采用表单提交事件读取数据并保存在数据库中。 www.abc.com 有一个针对 xyz.php 执行操作的表单。
这个问题在这里已经有了答案: JavaScript post request like a form submit (32 个答案) 关闭 9 年前。 我查看了不同的线程,但找不到合适的解决方案。
我有一个表单提交触发器和一个确认引导框,它显示在单击表单提交按钮上。在 bootbox 中确认如果用户同意我提交表单。我的问题是 onsubmit 在用户说是之前触发,并且当我在 bootbox 中调
我正在使用 JavaScript .submit() 函数提交我的表单。 form.submit(); 但是当我使用 addEventListener 来捕获我的提交事件时,它不起作用。 form.a
编辑:在考虑回答问题之前,请仔细阅读问题的所有内容。我既不是在生产代码中使用内联事件处理程序的可取性,也不是在实现我所引用的文章所 promise 的结果的最佳方法。这是关于Javascript语义和
这是我的形式,对我来说看起来不错。在这种形式中,我放置了这个按钮: 这是它调用的函数: function confirmSubmit() { // get the number of st
以下哪个 CSS 选择器更快? input[type="submit"] { /* styles */ } 或 [type="submit"] { /* styles */ } 只是好
在表单上添加提交按钮的符合标准的正确语义方式是什么?我不需要按钮中的图像或背景,只需要简单的文本,也许是带弯 Angular 的渐变背景(使用 CSS3)。这些是我所知道的方法: click her
我的 App.js 包含以下代码: var app = angular.module('githubApp', []); 我有 githubAppController 和以下代码: app.contr
jQuery 允许通过以下任一方式以编程方式触发表单提交: $('.js-form-class-hook').submit(); $('.js-form-class-hook').trigger('s
我有一个表单,其中一个按钮使用 onClick 事件提交。 " 此外,我有一个输入,当输入处于焦点状态时按下回车键时会触发 couponButton。 虽然它们都触发相同的事件 (.submit()
目前只是尝试实现这些按钮:http://web.archive.org/web/20110721191046/http://particletree.com/features/rediscoverin
我正在提交我的第一个构建以供 TestFlight beta 审查,在创建一个组后,添加 4 名团队成员添加我的构建,取消单击该框以表示我需要登录信息来测试该应用程序,我单击“提交”审查。” iTun
我有一个带有 onsubmit 属性的表单。我需要绑定(bind)一个新的提交事件,并且我需要在任何现有提交函数之前执行此事件。 下面的代码演示了这个问题。 Test
我是一名优秀的程序员,十分优秀!