moh*_*nia 2 iframe selenium cross-domain python-3.x
我怎么可以点击红色按钮,在这里从主机A(在这个例子中jsfiddle.net)使用硒蟒蛇?(java脚本限制策略错误不要让我这样做).我也不想直接点击红色按钮.谢谢.
el = driver.find_element_by_xpath("/ html/body/div 2/input")
webdriver.ActionChains(driver).move_to_element(el).click(el).perform()
保持红色按钮的iframe:
<iframe src="http://www.myhostb.blogfa.com/" width="500" height="300">
</iframe>
Run Code Online (Sandbox Code Playgroud)
重要提示:jsfiddle.net是Host A的成像
你需要使用 switch_to_frame()
driver.switch_to_frame("result")
driver.switch_to_frame(driver.find_element_by_css_selector("body>iframe"))
driver.find_element_by_css_selector("input.ex2").click()
Run Code Online (Sandbox Code Playgroud)
完成后iframe,您可以使用以下命令切换回顶部框架:
driver.switch_to_default_content()
Run Code Online (Sandbox Code Playgroud)