首页 文章

Selenium WebDriver Automation与NW.js和Chromium Extended Framework桌面应用程序在Web技术中实现

提问于
浏览
0

我正在尝试自动化我的应用程序,这是一个使用Web技术实现的独立桌面应用程序,以及使用NW.js的chrome嵌入式框架

我测试的应用程序是基于Web技术实现的桌面NW.JS要测试的应用程序实际上嵌入在Web工具包中,它使用铬并且是一个普通的窗口和浏览器无关 . 它没有使用任何传统浏览器(即firefox,IE或Safari或谷歌浏览器)我想知道是否可以使用selenium web驱动程序来测试NW.JS类应用程序 . 如果有人能帮助我,我将不胜感激

硒WebDriver自动代码如下

import java.io.File;    
import java.text.SimpleDateFormat;    
import java.util.Calendar;    
import java.util.Date;    
import java.util.Formatter;    
import java.util.Locale;    
import java.util.TimeZone;    
import org.openqa.selenium.WebDriver;    
import org.openqa.selenium.chrome.ChromeDriver;    
import org.openqa.selenium.chrome.ChromeOptions;

public class MyDummyTest

{

       public static void main(String args[])
       {    

            File chromium = new File("C:\\Program Files (x86)\\ChartInstaller Standalone\\nw.exe");
            System.setProperty("webdriver.chrome.driver","C:/Program Files (x86)/ChartInstaller Standalone/chromedriver2_server.exe");      
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--remote-debugging-port=9222");
            options.setBinary(chromium);
            WebDriver driver = new ChromeDriver(options);                                    
       }
}

但是当我执行此操作时,我会看到一个对话框(如下所示) . 任何人都可以帮我解决这个问题吗?我已经在Windows 7环境中安装了NW.js包 .

Dialog box Cannot extract package, failed to unzip the package file

1 回答

  • 0

    这是您的答案:您需要使用Selenium Web驱动程序的zip类

    http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html这里是课程详细信息页面 . 免费使用符合您要求的功能 . 我认为我的示例代码也应该有效

    https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/io/Zip.java

    这是java代码

    import java.io.File;
    import java.io.IOException;
    import java.util.concurrent.TimeUnit;
    
    import org.junit.Test;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxProfile;
    import org.openqa.selenium.firefox.internal.ProfilesIni;
    import org.openqa.selenium.io.Zip;
    
    public class tempUnit {
    
        public void test() {
    
            Zip zip = new Zip();
            try {
            zip.unzip(new File("D:\\TmpFS"), new File("D:\\TmpFS.zip"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    }
    

相关问题