Python 3.x 硒元素请求

Python 3.x 硒元素请求,python-3.x,selenium,selenium-webdriver,Python 3.x,Selenium,Selenium Webdriver,我无法使用Selenium库找到元素。我试过id,Xpath,什么都没试过。。。在html iframe或frameset上肯定有一些东西,但我也尝试了driver.switch_到.frame,但没有成功。 我是Python的初学者,所以,感谢您耐心的解释 Idea是使用脚本在公司内部网上输入数据来实现自动化 以下是我迄今为止尝试过的代码和一些注释: import selenium from selenium import webdriver import time driver = se

我无法使用Selenium库找到元素。我试过id,Xpath,什么都没试过。。。在html iframe或frameset上肯定有一些东西,但我也尝试了
driver.switch_到.frame
,但没有成功。 我是Python的初学者,所以,感谢您耐心的解释

Idea是使用脚本在公司内部网上输入数据来实现自动化

以下是我迄今为止尝试过的代码和一些注释:

import selenium
from selenium import webdriver
import time


driver = selenium.webdriver.Chrome(r'C:\Users\tvalente\PycharmProjects\TESTEs\descriptionCapture\chromedriver.exe')

driver.get('https://quest.slb.com/quest/QuestLogInx.asp?NextRptType=&NextQPID=') #this page is just an automatic login to redirect to another page

time.sleep(7)

driver.get('https://quest.slb.com/quest/IndexIE.asp') #as i dont know to use Selenium very well yet, to make sure im requesting the element on the correct page, i asked the browser to refresh at the redirected page. If there is a way to do it without refreshing the URL, also appreciate the help ! For example, if i click on a link which will redirect to a new page, do i need to use the driver.get('new page URL') again to work on the tags or there is another way ? 

time.sleep(4)

driver.switch_to.frame('navframe') #please see HTLM code below. this is the iframe.  
reportnumber = driver.find_element_by_id('strCriteria') #this is the text field tag id inside the iframe.    
reportnumber.send_keys('testandto') #This is what i want to text before submit
以下是HTML:


不确定如何在此处共享计算机中的图像…

请检查您的应用程序中是否有可用的帧

在DOM中搜索“iframe”,并确认该元素在框架内可用。 如果它在框架内,则需要在框架内切换控件,然后只有您可以处理该元素

在下面的框架内切换是语法之一:

driver.switchTo().frame(“frameid”)


然后在WebElement上执行任何操作。

无论如何,您不应该包含HTML的图像。尝试编辑您的文章,以包含HTML行和您想要查找的元素。此外,在切换到iframe之前,您需要将Selenium指向iframe。尝试
iframe=driver。通过xpath('//frame[@name=“frame\u name\u here”]')
查找\u元素,\u,然后
driver。切换到.frame(iframe)
。此外,每次重新加载iframe中的内容时,都需要使用上述命令重新查找框架的元素。