即使在使用selenium testng指定firefox后,IE浏览器也会打开

时间:2012-05-29 15:26:53

标签: eclipse selenium automation testng

我正在使用Eclipse IDE并使用testNG框架。 我已经指定了firefox,但测试运行器在Firefox中打开,测试在IE中执行。

这是我的代码:

public class Flipkart extends SeleneseTestNgHelper {

    @BeforeTest
    public void setup()
    {
           selenium = new DefaultSelenium("localhost" ,4444, "*firefox", "http://www.flipkart.com");
           selenium.start();
           selenium.windowMaximize();
    }

    @Test 
    public void testFlipkart() throws Exception {
        selenium.open("http://www.flipkart.com");
        verifyEquals(selenium.getTitle(), "Online Shopping India | Buy Books, Mobiles, Cameras, Laptops, Electronics, Accessories, Lifestyle Products | Flipkart.com");
        verifyTrue(selenium.isTextPresent("Featured:"));
    }

}

有没有人遇到同样的问题。请说明代码有什么问题。

4 个答案:

答案 0 :(得分:0)

将eclipse默认浏览器更改为firefox(有时会有帮助) 将firefox添加到类路径。另外看看你使用的firefox版本应该与selenium兼容

答案 1 :(得分:0)

使用*chrome代替*firefox

另外,检查selenium服务器是否已启动。

答案 2 :(得分:0)

I was also getting same problem, Try out below  code for Solution this will help you

public static String browser="firefox";  //declare Browser this in the class heading.


@BeforeSuite

 public void setupBeforeSuite() throws Exception{
selenium = new DefaultSelenium("localhost", 4444,browser, "http://www.google.com");
selenium.start();
  }

答案 3 :(得分:0)

您可以尝试以下步骤::

*STEP 1* : import org.openqa.selenium.firefox.FirefoxDriver;
         import org.openqa.selenium.WebDriver;
         import org.openqa.selenium.WebElement;

*Step 2* : WebDriver driver = new FirefoxDriver();

*Step 3* : driver.get("http://www.google.com");
相关问题