1

以下是似乎無法執行的測試用例代碼。有沒有Firefox的配置問題?無法訪問瀏覽器:會話未創建異常

package testOperations; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.testng.annotations.BeforeClass; 
import org.testng.annotations.BeforeTest; 
import org.testng.annotations.Test; 

public class FunctionalTest { 

    //Code for launching the required link into browser 

    WebDriver driver; 

    @BeforeTest 

    public void launchUrl() { 

    System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver/geckodriver.exe"); 
     driver = new FirefoxDriver(); 

     driver.get("https://letskodeit.teachable.com/p/practice"); 

    } 

在運行代碼時,只有空白瀏覽器窗口正在打開,並且測試用例失敗。

@Test 

    public void radioButtoncheck() { 

    boolean list = driver.findElements(By.tagName("radio")).get(2).isSelected(); 

     if (list!=true) { 

      driver.findElement(By.id("hondaradio")).click(); 
     } 
     else { 

      driver.findElement(By.id("benzradio")).click(); 
     } 

    } 

} 

Output screenshot

+0

能否請附上錯誤輸出運行測試,當你? – Thibstars

+0

測試用例失敗輸出屏幕截圖 – User6

+0

我正在使用硒獨立3.0.1和geckodriver以及它的顯示空白morzilla瀏覽器選項卡打開。 – User6

回答

0

代碼錯誤@

System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver/geckodriver.exe"); 

使用

System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver//geckodriver.exe"); 

「//」 應放置,而不是 「/」

+0

if(browser.equalsIgnoreCase(「火狐 「)){ \t \t \t \t \t \t \t \t \t System.setProperty(」 webdriver.gecko.driver」, 「C://MavenTest//driver//geckodriver.exe」); \t \t \t \t \t \t \t \t \t驅動=新FirefoxDriver(); \t \t \t \t \t \t \t} \t \t \t \t否則,如果(browser.equalsIgnoreCase( 「鉻」)){ \t \t \t \t \t \t \t \t \t System.setProperty( 「webdriver.chrome.driver」 「C:// // MavenTest司機// chromedriver。exe文件「); \t \t \t \t \t \t \t \t \t驅動=新ChromeDriver(); \t \t \t \t \t \t \t}我們爲了check.So IGOT使用這個代碼,鉻驅動程序是工作正常Geckodriver 64bit版有沒有新的依賴關係 – User6

+0

要使用geckodriver,你的firefox版本必須高於47。請檢查並更新到最新版本 – RamaKrishna

1

最後我得到了answer.Do看是否有人獲得配置失敗與最新geckdriver和morzilla瀏覽器版本

使用此

System.setProperty("webdriver.firefox.marionette", "C://MavenTest//driver/geckodriver.exe"); 
相關問題