Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用selenium和python定位文本输入元素_Python_Selenium_Xpath_Selenium Chromedriver - Fatal编程技术网

无法使用selenium和python定位文本输入元素

无法使用selenium和python定位文本输入元素,python,selenium,xpath,selenium-chromedriver,Python,Selenium,Xpath,Selenium Chromedriver,我正在尝试使用Selenium和Python在网页()上查找一个元素,并希望找到医药产品名称的第一个文本输入 我得到这个错误: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='nimi'][@type='text']"} 我目前正在使用以下代码: clear_button = driver.find_element_by_xpath("//input

我正在尝试使用Selenium和Python在网页()上查找一个元素,并希望找到医药产品名称的第一个文本输入

我得到这个错误:

Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='nimi'][@type='text']"}
我目前正在使用以下代码:

clear_button = driver.find_element_by_xpath("//input[@name='nimi'][@type='text']")

我不熟悉Python和Selenium。请帮我解决这个问题

您要查找的字段位于
iframe
中。 您需要首先识别并切换到该
iframe

iframe=driver.switch_to.frame('_com_liferay_iframe_web_portlet_IFramePortlet_INSTANCE_1UG85fOFT8Za_iframe')
input_field = driver.find_element_by_xpath("//input[@name='nimi']")

无法定位元素的原因是输入框被一个框架隐藏。也许您应该使用
切换到.frame()
来切换到它。

请添加您要查找的元素的html。谢谢,我现在可以找到它了。