无法使用send_keys进行发送 python selenium。

问题描述 投票:0回答:1

大家好

我想在搜索框中使用send_keys发送一些文本数据,如图所示,但无法发送下去。给我出错。 目前的重点是 "简短的描述",它需要被移动到搜索框,并需要发送 尝试发送文本信息使用xpath,但没有帮助。Id "一直在变化,所以也没有帮助我。

搜索框是我试图发送文本数据的文本框。

以下是我复制元素后得到的元素网。

<input id="5e3dc64a2f3010109e9a3c96f699b632_text" placeholder="Search" class="form-control" style="width: 150px;" name="5e3dc64a2f3010109e9a3c96f699b632_text" aria-describedby="5e3dc64a2f3010109e9a3c96f699b632_describedby">

下面是xpath。

//*[@id="5e3dc64a2f3010109e9a3c96f699b632_text"]

下面是我用来发送的部分代码。

search_box = driver.find_element(By.XPATH, "//span[@class='form-control']")
search_box.click()
search_box.send_keys("Unable to access the shared folder")
python-3.x selenium selenium-webdriver automation servicenow
1个回答
0
投票

其中一个问题可能是存在其他元素,这些元素共享相同的类名.调试步骤:你可以试试。

search_box.click()
driver.implicitly_wait(10)

在等待过程中,观察搜索框是否被高亮显示。如果没有,那么selenium可能无法定位到webElement,并且存在多个共享相同类名的web元素,这可能是问题所在。

© www.soinside.com 2019 - 2024. All rights reserved.