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激活inspect窗口?_Selenium_Iframe_Automation_Chrome Web Driver - Fatal编程技术网

如何使用selenium python激活inspect窗口?

如何使用selenium python激活inspect窗口?,selenium,iframe,automation,chrome-web-driver,Selenium,Iframe,Automation,Chrome Web Driver,我正在尝试在chrome浏览器中实现插件的自动化。需要打开检查窗口并对检查窗口执行操作。我能够使用robot类打开inspect窗口并在inspect GUI元素之间导航,但无法在inspect窗口中执行HTML DOM操作。检查窗口包含iFrame,但我无法从主页切换到这些iFrame。当我尝试在活动页面上列出iframe时,它只显示主页上的iframe,而不是检查窗口中的iframe。我想切换到使用iFrame或任何其他方式(如果有)检查窗口。到目前为止,我编写的代码是 from pyrob

我正在尝试在chrome浏览器中实现插件的自动化。需要打开检查窗口并对检查窗口执行操作。我能够使用robot类打开inspect窗口并在inspect GUI元素之间导航,但无法在inspect窗口中执行HTML DOM操作。检查窗口包含iFrame,但我无法从主页切换到这些iFrame。当我尝试在活动页面上列出iframe时,它只显示主页上的iframe,而不是检查窗口中的iframe。我想切换到使用iFrame或任何其他方式(如果有)检查窗口。到目前为止,我编写的代码是

from pyrobot import Robot
from selenium import webdriver    
from selenium.webdriver.common.keys import Keys
import time

browser = webdriver.Chrome()
browser.get('https://chrome.google.com/webstore/detail/dynamic-assessment-plugin/fnapgcgphlfhecijolobjodbbnjjpdga')
browser.maximize_window()
browser.implicitly_wait(15)
browser.find_element_by_css_selector("[aria-label='Add to Chrome']").click()

time.sleep(3)
robot = Robot()
robot.addExtension() # customized Robot class to add extension

robot.newtab() # customized Robto class for new tab

browser.switch_to.window(browser.window_handles[1])

browser.get('http://www.walmart.com')    

time.sleep(8)   
robot.inspectElement() # Customized Robot class for inspecting (Ctrl+shift+i)

在C中创建chromedriver对象时,这将起作用, 您需要通过在chromeoptions中添加参数来提供配置文件

ChromeOptions options = new ChromeOptions();
options.AddArguments("--auto-open-devtools-for-tabs");
browser = new ChromeDriver(DrivePath, options, TimeSpan.FromSeconds(100));
您也可以尝试按F12,它将打开检查窗口 然后可以使用Robot类或Windows。自动化脚本的表单库管理多个窗口表单

您的代码是用python编写的,java和C都提供了相同的答案。 您还可以访问以下网址了解更多信息:


分享你尝试过的代码far@AshokkumarGanesan代码更新了。我想你还不清楚这个问题。我可以打开“检查”窗口,但无法在“检查”窗口上选择元素。为什么您要尝试从“检查”窗口中选择元素。继续正确使用硒。您不需要通过inspect元素来选择元素,而这正是selenium发挥有用作用的地方。您可以通过selenium使用这些东西。如果您想要data use.innerHTML中的任何元素,如果您想要任何属性值use.GetAttribute,您需要关闭此问题。如何说“您不需要通过inspect element选择元素”?该插件连接到包含HTMLDOM的inspect窗口。我需要切换到检查窗口中的框架。这不是关于结束这个问题,这是一个真正的问题,到目前为止还没有关于这个问题的讨论。“不从检查窗口检查”是什么意思?您是否已检查页面是否正确。切换回活动窗口,然后再次收集iframe,您肯定会得到