2013-06-04 75 views
1

我在尝试让我的Fluentlenium代码在WebDriver Firefox驱动程序内运行时遇到问题。我需要Fluentlenium在WebDriver Firefox Driver内执行,而不是打开它自己的浏览器。我想我需要重写这个,但我不确定如何做到这一点。任何帮助将不胜感激。谢谢!以下是我对代码:如何在Selenium Webdriver Firefox驱动程序中运行Fluentlenium代码?

WebDriver driver = new FirefoxDriver(); 


@Test 
public void create_a_picklist() 

{

// Go to Page 
    goTo("http://www.google.com"); 

}

它打开两个浏览器会发生什么事。一个来自Firefox驱动程序,另一个来自Fluentlenium的goTo默认浏览器。我需要它在Firefox Driver窗口中运行此代码,而不是从Fluentlenium中打开它自己的窗口。

回答

0

好的。看起来我知道了。这是我做重写浏览器:

public class Test extends FluentTest { 

    // Defines the Driver 
    public WebDriver driver = new FirefoxDriver(); 

    // Overrides the default driver 
    @Override 
    public WebDriver getDefaultDriver() { 
     return driver; 
    } 

    @Test 
    public void go_to_google() 
    { 

    goTo("http://www.google.com"); 

    } 
} 
+0

现在你应该可以在Fluentlenium内运行任何硒驱动程序代码。 –

1

默认情况下,它launchs Firefox浏览器,这样是足够:

public class Test extends FluentTest { 

    @Test 
    public void go_to_google() 
    { 

    goTo("http://www.google.com"); 

    } 
} 

仅此而已:)

+0

是的。我试图真正实现的是让驱动程序使用defaultDriver。所以我可以在defaultDriver中运行任何driver.xxx代码。 –

相关问题