简体   繁体   English

识别IE11 32位C#中的弹出窗口Selenium

[英]Identify popup window Selenium in IE11 32 bit C#

I am having trouble identifying a popup to handle it. 我在确定要处理的弹出窗口时遇到了麻烦。 This is what I tried: 这是我尝试的:

            string dialog4;
            string dialog5;
            try
            {
                IAlert alert = driver.SwitchTo().Alert();
                dialog4 = alert.Text;
                alert.Accept();
                dialog5 = "nothing alert";
            }
            catch (NoAlertPresentException f)
            {
                try
                {
                    dialog4 = driver.SwitchTo().Frame(0).Title;// "dialog4";//
                    dialog5 = driver.SwitchTo().Frame(1).Title;// "dialog5";// 
                }
                catch (NoSuchFrameException e)
                {
                    try
                    {
                        dialog4 = driver.SwitchTo().Window("iHTKK").Title;
                        dialog5 = "nothing window";
                    }
                    catch
                    {
                        dialog4 = "nothing 4";
                        dialog5 = "nothing 5";
                    }
                }
            }
  • The code wait 10 seconds and the webdrive wait 30 seconds after clicking the red-highlighted button to make sure that the pop-up has time to be caught. 单击红色突出显示的按钮后,代码将等待10秒钟,Web驱动器将等待30秒钟,以确保弹出窗口有时间被捕获。
  • And the code return "nothing 4" and "nothing 5". 并且代码返回“ nothing 4”和“ nothing 5”。
  • xPath doesn't work very well in this project, I don't know why but I tried with different elements before but xPath do not work. xPath在该项目中不能很好地工作,我不知道为什么,但是我之前尝试过使用其他元素,但是xPath不起作用。
  • I could not open F12 unless I response to this pop-up. 除非对此弹出窗口做出响应,否则无法打开F12。 I could open it before and after the existence of this pop-up . 我可以在此弹出窗口存在之前和之后打开它
  • I also tried to find in the website (all HTML and .js files) for the information in the pop-up box using search function in Developer tool (F12) in Debugger and Dom Explorer tabs. 我还尝试使用调试器和Dom Explorer选项卡中的Developer tool(F12)中的搜索功能在网站(所有HTML和.js文件)中找到弹出框中的信息。 Nothing found. 没有发现。 This is not my website. 这不是我的网站。
  • I attached the screen-shot with Window spy (an utility comes with AutoHotkey help identify windows). 我在屏幕截图中附加了Window spy(AutoHotkey帮助附带的实用程序,用于识别Windows)。 The pop-up was created by a process call "jp2lancher.exe". 弹出窗口是由进程调用“ jp2lancher.exe”创建的。 My Java version is 8.x 32 bit if that's of concern. 如果担心的话,我的Java版本是8.x 32位。 While it seem like the pop-up is from a different process, I can't interact with IE until I response to that pop-up. 虽然弹出窗口似乎是来自不同的过程,但是直到响应该弹出窗口后,我才能与IE进行交互。 However, I can close it via "Close all windows" action in the task bar and the pop-up will still exist. 但是,我可以通过任务栏中的“关闭所有窗口”操作将其关闭,弹出窗口仍然存在。

What else can I do to identify this pop-up? 我还能做些什么来识别此弹出窗口? 弹出屏幕截图

After testing around, it's confirmed that Window Spy tool is a good way to identify if a pop-up is generated by the browser/driver. 经过测试后,可以确认Window Spy工具是识别浏览器/驱动程序是否生成弹出窗口的好方法。 In ahk_exe line, it will say a window is run by which executable file. ahk_exe行中,它将说一个窗口由哪个可执行文件运行。 In my case, the pop-up is indeed a Java plug-in that is loaded from the website and run on my computer. 就我而言,弹出窗口确实是一个Java插件,可以从网站上加载并在我的计算机上运行。 I finally use AutoIt to handle that window. 我终于使用AutoIt处理该窗口。 If anyone use AutoIt, keep in mind that it is a DIFFERENT language and all actions must be initiated in its format. 如果有人使用AutoIt,请记住这是一种不同的语言,所有操作都必须以其格式启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM