[英]switch to add-on pop-up window interface selenium python
As you can see usually when we click on add-on icon it creates a "pop-up" or a "window", literally another html file as i evidenced., not embodied in main html.正如您通常看到的那样,当我们单击附加图标时,它会创建一个“弹出窗口”或“窗口”,实际上是另一个 html 文件,正如我所证明的那样,没有体现在主 html 中。 I wonder how to switch from main tab to add-on interface and work on it (like click button etc.) without using pyautogui & image detection: it would be too easy;)
我想知道如何在不使用 pyautogui 和图像检测的情况下从主选项卡切换到附加界面并处理它(如单击按钮等):这太容易了;)
I guess you are talking about frames.我猜你在谈论框架。 A frame is a part of a web page or browser window which displays content independent of its container, with the ability to load content independently (source: https://en.wikipedia.org/wiki/Frame_(World_Wide_Web) )
框架是 web 页面或浏览器 window 的一部分,它显示独立于其容器的内容,具有独立加载内容的能力(来源: https_(World_Wide_Web) 。
You can switch to another frame with the following command:您可以使用以下命令切换到另一个帧:
driver.switch_to.frame()
As parameter for the frame() function, you have 3 options: frame index (0,1,2, etc), name (an id that the developer has given to the frame, or webelement (ie a unique element in that frame, which you can find as every other element with:作为 frame() function 的参数,您有 3 个选项:框架索引(0、1、2 等)、名称(开发人员为框架提供的 id 或 webelement(即该框架中的唯一元素,您可以通过以下方式找到所有其他元素:
driver.switch_to.frame(driver.find_element_by_...)
I hope I helped:)我希望我有所帮助:)
I am not sure how to click add-on icon on Chrome just using Selenium.我不确定如何仅使用 Selenium 在 Chrome 上单击附加图标。 Actually, I don't think chromedriver has provided some methods to click on the chrome toolbar, so maybe you can't write codes to do it.
实际上,我认为chromedriver没有提供一些点击chrome工具栏的方法,所以也许你不能编写代码来做到这一点。
But, there is another way that works.但是,还有另一种可行的方法。
Manage extensions
on the list, a new tab opens which has url like this chrome://extensions/?id=cfhdojbkjhnklbpkdaibdccddilifddb
. Manage extensions
在列表中,打开一个新选项卡,其中包含 url 像这样chrome://extensions/?id=cfhdojbkjhnklbpkdaibdccddilifddb
。Options
on the list, a new tab opens, url like this chrome-extension://cfhdojbkjhnklbpkdaibdccddilifddb/options.html
.Options
,打开一个新选项卡,url 像这样chrome-extension://cfhdojbkjhnklbpkdaibdccddilifddb/options.html
In other words, all of the Chrome extensions configuration pages are actually HTML pages.换句话说,所有的 Chrome 扩展配置页面实际上都是 HTML 页面。 So you can open the configuration page directly, and click button or do other actions you want.
因此,您可以直接打开配置页面,然后单击按钮或执行其他操作。
extensionManagePage = "chrome://extensions/?id=cfhdojbkjhnklbpkdaibdccddilifddb";
driver.get(extensionManagePage);
// or
extensionOptionsPage = "chrome-extension://cfhdojbkjhnklbpkdaibdccddilifddb/options.html";
driver.get(extensionOptionsPage);
// click button etc.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.