Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.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
Java 这是什么样的窗口?我如何使用Selenium处理它?自动驾驶?_Java_Selenium Webdriver - Fatal编程技术网

Java 这是什么样的窗口?我如何使用Selenium处理它?自动驾驶?

Java 这是什么样的窗口?我如何使用Selenium处理它?自动驾驶?,java,selenium-webdriver,Java,Selenium Webdriver,我有一个Windows Detective声称是“MozillaDialogClass”窗口的对话框,当然我现在正在Firefox中测试 这是窗口的图像 AutoIt IDE无法识别它。Windows Defender看不到它的任何属性,因此我不知道它的名称或其他任何信息。其中一位开发者说这是一个特定于浏览器的窗口。(不管那是什么,如果是的话,为什么什么都看不见呢?) 有人对这个有什么想法吗?我被难住了。这是您的网络浏览器的本机对话框。所以用硒来处理这个问题并不容易。你想在里面测试什么 有关一

我有一个Windows Detective声称是“MozillaDialogClass”窗口的对话框,当然我现在正在Firefox中测试

这是窗口的图像

AutoIt IDE无法识别它。Windows Defender看不到它的任何属性,因此我不知道它的名称或其他任何信息。其中一位开发者说这是一个特定于浏览器的窗口。(不管那是什么,如果是的话,为什么什么都看不见呢?)


有人对这个有什么想法吗?我被难住了。

这是您的网络浏览器的本机对话框。所以用硒来处理这个问题并不容易。你想在里面测试什么

有关一些阅读资料,请参见以下问题:
处理这一问题的最佳方法是使用。下面是使用SikuliX的示例场景。基本上,SikuliX自动化了运行Windows、Mac或某些Linux/Unix的桌面计算机屏幕上的任何内容。它使用OpenCV支持的图像识别来识别和控制GUI组件。在无法轻松访问GUI的内部结构或要操作的应用程序或网页的源代码的情况下,这非常方便

下面是一个hello world示例。点击屏幕上的spotlight图标,等待spotlight的输入窗口出现,然后键入“hello world”并点击ENTER

import org.sikuli.script.*;

public class TestSikuli {

    public static void main(String[] args) {
            Screen s = new Screen();
            try{
                    s.click("imgs/spotlight.png", 0);
                    s.wait("imgs/spotlight-input.png");
                    s.type(null, "hello world\n", 0);
            }
            catch(FindFailed e){
                    e.printStackTrace();
            }

    }

 }

您可以找到sikuli

而不是处理下载窗口,您可以设置Firefox自动将文件下载到文件夹:

FirefoxProfile profile=新的FirefoxProfile();
profile.setPreference(“pdfjs.disabled”,true);//禁用内置查看器
profile.setPreference(“browser.download.folderList”,2);
profile.setPreference(“browser.download.dir”,“C:\\Windows\\temp”);
setPreference(“browser.download.panel.show”,false);
setPreference(“browser.helperApps.neverAsk.openFile”,”;
setPreference(“browser.helperApps.neverAsk.saveToDisk”、“application/vnd.ms excel”);
WebDriver=新的FirefoxDriver(配置文件);
驱动程序。获取(“http://www.exinfm.com/free_spreadsheets.html");
driver.findElement(By.linkText(“资本预算分析”))。单击();
或使用默认应用程序自动打开文件:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("pdfjs.disabled", true);  // disable the built-in viewer
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.panel.shown", false);
profile.setPreference("browser.helperApps.neverAsk.openFile", "application/vnd.ms-excel");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "");

WebDriver driver = new FirefoxDriver(profile);
driver.get("http://www.exinfm.com/free_spreadsheets.html");
driver.findElement(By.linkText("Capital Budgeting Analysis")).click();
请注意,您需要根据您的文件更新MIME类型(
application/vnd.ms excel
)。 MIME类型是响应头中的
内容类型

如果您只想关闭对话框,那么我将使用AutoIt:

WinWait("[CLASS:MozillaDialogClass]", "", 10)
WinClose("[CLASS:MozillaDialogClass]")

我基本上只想点击OK按钮并关闭它,这样它就会打开excel文档。这似乎很困难。英雄联盟