gpt4 book ai didi

python - 无法将 send_keys 发送到工具提示所覆盖的网络元素

转载 作者:行者123 更新时间:2023-11-28 18:57:34 24 4
gpt4 key购买 nike

我尝试将价格填充到输入元素中。我尝试了很多方法但都失败了,我意识到它可能被另一个元素覆盖了。当我将鼠标指向该字段时,它会自动显示工具提示。而且我还看到检查框中出现了一些 HTML 代码行。

图 1:当我没有将鼠标指向该字段时我的屏幕。

i

图2:鼠标移到那个字段时的画面

i

下面是我的一些尝试:

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>

请帮我克服这个限制。谢谢

补充的话:这个字段上面的一些字段也有一些工具提示结构,但我可以通过上面的一些解决方案轻松并成功地填写。但我不知道为什么这个字段会成为一个强约束。例如这个字段(蓝色高亮框): picture 3

最佳答案

您应该尝试使用 ActionChainsmove_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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com