【发布时间】:2021-05-17 01:36:50
【问题描述】:
我遇到了一个找不到元素的问题 我的代码:
Dim bot As WebDriver
Set bot = New WebDriver
bot.Start "chrome"
bot.Get "http://..."
bot.FindElementByName("userName").SendKeys "text"
bot.FindElementByName("password").SendKeys "text"
bot.FindElementByClass("ButtonLast").Click
bot.FindElementByName("searchField").SendKeys "text"
Stop
HTML:
<input
class="SearchRoundCorner"
onblur="searchFieldInnerTxt(this);"
onfocus="searchFieldInnerTxt(this);"
style="width: 150px; padding-left: 20px; color: rgb(128, 128, 128);"
type="text"
name="searchField"
value="search"
title=""
onkeypress="if ((window.event && window.event.keyCode == 13)|| event.which==13){ document.ListView.pageNo.value=1;document.ListView.saveSelection.value = 0;submitForm(document.ListView);return false; }"
/>
它运行良好,直到我到达那一行-bot.FindElementByName("searchField").SendKeys "text"
错误:
Error message:Run-Time Error 7 NoSuchElementError Element not found for name=searchfield
【问题讨论】:
-
请用网址、整页源代码和图片编辑您的问题。
-
你的 dom 中有搜索按钮,还是需要等待一段时间?..
标签: excel vba selenium xpath css-selectors