- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试将价格填充到输入元素中。我尝试了很多方法但都失败了,我意识到它可能被另一个元素覆盖了。当我将鼠标指向该字段时,它会自动显示工具提示。而且我还看到检查框中出现了一些 HTML 代码行。
图 1:当我没有将鼠标指向该字段时我的屏幕。
图2:鼠标移到那个字段时的画面
下面是我的一些尝试:
price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
driver.execute_script('arguments[0].innerHTML = "100000";', price)
结果:什么都不做,没有错误
或
price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
browserdriver.execute_script("$(arguments[0]).click();", price)
price.send_keys("10000")
或
price=WebDriverWait(browserdriver, 10).until(EC.element_to_be_clickable((By.XPATH,"//input[@id='inputProductPrice']")))
price.click()
price.send_keys("10000")
或
price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
price.click()
price.send_keys("10000")
或
price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
actions.move_to_element(price).click(price).perform()
price.send_keys("10000")
我确信 XPath 是正确的并且该元素在屏幕上,因为我可以将键发送到该行中的类似字段(图 1 中名为“2”的字段带有蓝色突出显示框)。
html:
<div class="col-md-2">
<input type="text" class="form-control" placeholder="Nhập giá" id="inputProductPrice" title="" data-toggle="tooltip" data-original-title="(Trên 8.000 VNĐ)" data-bind="moneyMask: ProductPriceForAll">
</div>
请帮我克服这个限制。谢谢
补充的话:这个字段上面的一些字段也有一些工具提示结构,但我可以通过上面的一些解决方案轻松并成功地填写。但我不知道为什么这个字段会成为一个强约束。例如这个字段(蓝色高亮框):
最佳答案
您应该尝试使用 ActionChains
和 move_to_element_with_offset
:
action = ActionChains(browserdriver)
price = WebDriverWait(browserdriver, 10).until(EC.element_to_be_clickable((By.XPATH,"//input[@id='inputProductPrice']")))
action.move_to_element_with_offset(price, 5, 5)
action.click().perform()
您可以使用偏移量来找到可点击的区域...
希望对你有帮助!
关于python - 无法将 send_keys 发送到工具提示所覆盖的网络元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56542795/
我正在尝试构建一个函数来清除字段和 send_keys,但出现错误。看我的代码: base.py class Page(object): def clear_sendkeys(self, *l
我想将文本发送到页面的文本框。 这是页面上的隐藏元素: Topics 我可以点击文本框但无法发送文本的代码: textbox = [tag for tag in driver.find_elemen
我正在编写一个用于填写表格的脚本。它将具有特定值的字符串发送到应输入该值的文本字段。然而,虽然文本字段总是被输入,但字符有时会变得困惑。例如,在一个字段中,要输入的值为: 42042042042042
我正在使用带有 chromedriver 的 Python Selenium 进行自动化测试。 下面是代码示例: inputElement.send_keys(2356785)
我正在自动化一个在线应用程序,并试图让每个“.send_keys()”更加真实。 id 不是立即用“name@email.com”猛击文本字段,而是在击键之间有一个小的延迟,这样看起来就像是人在打字而
我想从 Selenium 切换到 Poltergeist,但我需要模拟一个条形码扫描仪,看起来像键盘输入 标签。我将此代码与 Selenium 一起使用: native.send_keys(send_
我有一个脚本可以打开 eBay 并自动化购买过程,并且它可以工作......一段时间。经过一系列循环后,它随机开始跳过向文本字段发送数据。该脚本第一次总是会完美运行,但在第二次或第十次迭代之间偶尔会崩
我正在自动化一个在线应用程序,并试图让每个“.send_keys()”更加真实。 id 不是立即用“name@email.com”猛击文本字段,而是在击键之间有一个小的延迟,这样看起来就像是人在打字而
在Selenium中我想输入一个测试字符串“hello'world”,但是网页的文本框变成了“helloworld”。就好像撇号不存在一样。将 "'" 替换为 chr(39) 或拆分字符串也不起作用。
我是自动化领域的新手。我正在尝试在 Omegle 的文本框中输入一个字符串并按 Enter 键,但它显示了一个错误: selenium.common.exceptions.ElementNotInte
我正在尝试在Python中使用Selenium,因为我是这样做的初学者,所以我无法让send_key工作,但很可能它是直接的,我错过了一些东西。 这是我迄今为止所做的示例: from selenium
我尝试将价格填充到输入元素中。我尝试了很多方法但都失败了,我意识到它可能被另一个元素覆盖了。当我将鼠标指向该字段时,它会自动显示工具提示。而且我还看到检查框中出现了一些 HTML 代码行。 图 1:当
当我用 PhantomJS 和 selenium 运行我的代码时,res 显示 act,但是在 send_keys 中代码不会继续,只是停留在,没有错,没有任何答案,也没有停留。我只想知道为什么. r
这个问题已经有答案了: Stale element exception python (2 个回答) Selenium clicks one time, but next click returns
我正在使用selenium来抓取twitter(不使用api只是练习selenium),当它进入以下页面时需要登录,我使用以下代码来找到登录输入字段,然后发送用户名和密码字符串: from selen
问题 我正在尝试通过键入页码并单击回车来使用 selenium 更改数据库的页面(ReferenceUSA,需要付费或大学证书),但要注意的是搜索框位于 div 标记中。 send_keys() 仅适
我的问题:我有一个填充字段的方法,但问题是 selenium 没有将完整的字符串发送到该字段,所以我的断言在验证时失败了。 我的代码: var webdriver = require('seleniu
我正在尝试使用 selenium 的 send_keys 将表情符号字符发送到具有以下 python 代码的文本框。 browser = webdriver.Chrome(chrome_options
我知道如何用下一个代码慢慢打字: elem = driver.find_element_by_id("mainCommentForm") text = "To type text here" for
我正在尝试将_keys 发送到 webelement 但每次我都会收到此错误 driver.send_keys("admin") AttributeError: 'WebDriver' object
我是一名优秀的程序员,十分优秀!