Selenium Webdriver在Sikuli脚本之后停止运行

时间:2017-06-27 15:50:43

标签: java selenium webdriver sikuli

我试图用Selenium Webdriver运行一个简单的java脚本,但我还必须使用Sikuli,因为测试需要打开并与浏览器扩展交互。我的问题是Webdriver测试在Sikuli脚本之后停止运行。

我尝试使用driver.switchTo().defaultContent();切换到默认内容,但它不起作用。 有人知道如何继续运行Webdriver测试吗?您可以看到我的测试模板:

public class LoginTest {

    public static void main(String[] args) throws FindFailed{

    //Add the extension code in the project
    ChromeOptions options = new ChromeOptions ();
    options.addExtensions (new File
            ("Path to the extension"));
    DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    ChromeDriver driver = new ChromeDriver(capabilities);
    driver.get("chrome-extension"); 

    //Login on a website + extension
        driver.get("url");
        driver.findElement(By.id("nav-login-link")).click();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.findElement(By.name("auth_id")).sendKeys("username");
        driver.findElement(By.name("auth_secret")).sendKeys("password");
        driver.findElement(By.className("button-wrapper")).click();

    //Opens the Extension with Sikuli and continues on browser
        Screen screen = new Screen();

        screen.find("icon.png");
        screen.click("icon.png");
        screen.click("icon.png");
        screen.wait("popup.png");
        screen.click("selector.png");
        screen.click("search.png");
        screen.type("country.png");
        screen.click("flag.png");
        screen.click("browser.png");
        screen.type("url"+Key.ENTER);

    //Interact on browser with Webdriver - Login (*HERE IS WHERE THE THE TEST STOPS RUNNING*)
        driver.switchTo().defaultContent();
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//a[@href='/login']")).click();
}
}

0 个答案:

没有答案