2012-05-29 62 views
0

我正在使用Eclipse IDE並使用testNG框架。 我已經指定了Firefox,但測試運行器在Firefox中打開並且測試在IE中執行。IE瀏覽器在使用selenium testng指定firefox後打開

這裏是我的代碼:

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:")); 
    } 

} 

有沒有人遇到同樣的問題。請建議代碼有什麼問題。

+0

什麼是在窗口 - > Web瀏覽器菜單中選擇您所選擇的選擇嗎? –

+0

@Traroth它的Firefox – Rohit

回答

0

將eclipse默認瀏覽器更改爲firefox(有時幫助) 將firefox添加到類路徑中。也看看你使用的這個firefox版本應該與硒兼容

+0

我將eclipse默認瀏覽器更改爲Firefox,我的Firefox版本是12.0,並且它也與Selenium兼容。但我仍面臨同樣的問題。 – Rohit

+0

嘗試舊版本的Firefox,應該這樣做。 – Acid

+0

我也改爲* googlechrome ..仍然在IE中執行測試。谷歌瀏覽器的一個實例打開,但它沒用。 – Rohit

0

使用*chrome而不是*firefox

另外,檢查硒服務器是否啓動。

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(); 
    } 
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"); 
相關問題