2017-02-06 3 views
0

私は以下のコードを試しましたが、コードを実行しているときに「選択を開始できず、最近起動しません」というメッセージが表示されますポップアップは、Eclipseでコードを実行中に「起動できません」と表示されます

uはこれで私を助けてくださいすることができ

....

おかげ

全コード:

import org.openqa.selenium.By; 

import org.openqa.selenium.WebDriver; 

import org.openqa.selenium.WebElement; 

import org.openqa.selenium.firefox.FirefoxDriver; 

public class Gmail_Login { 

/** 

    @param args 

*/ 

public static void main(String[] args) { 

// objects and variables instantiation 

WebDriver driver = new FirefoxDriver(); 

String appUrl = "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier"; 

// launch the firefox browser and open the application url 

driver.get(appUrl); 

// maximize the browser window 

driver.manage().window().maximize(); 

// declare and initialize the variable to store the expected title of the webpage. 

String expectedTitle = " Sign in - Google Accounts "; 

// fetch the title of the web page and save it into a string variable 

String actualTitle = driver.getTitle(); 

// compare the expected title of the page with the actual title of the page and print the result 

if (expectedTitle.equals(actualTitle)) 

{ 

System.out.println("Verification Successful - The correct title is displayed on the web page."); 

} 

else 

{ 

System.out.println("Verification Failed - An incorrect title is displayed on the web page."); 

} 

// enter a valid username in the email textbox 

WebElement username = driver.findElement(By.id("Email")); 

username.clear(); 

username.sendKeys("TestSelenium"); 

// enter a valid password in the password textbox 

WebElement password = driver.findElement(By.id("Passwd")); 

password.clear(); 

password.sendKeys("password123"); 

// click on the Sign in button 

WebElement SignInButton = driver.findElement(By.id("signIn")); 

SignInButton.click(); 

// close the web browser 

driver.close(); 

System.out.println("Test script executed successfully."); 

// terminate the program 

System.exit(0); 

} 

} 

答えて

0

I EXあなたが共有したコードが表示されます。あなたが言及したエラーは投げられませんでした。私があなたのコードに行った唯一の変更は、最新のSeleniumライブラリを使用しているため、システムのプロパティwebdriver.gecko.driverです。Firefoxを使用するにはこのパスを設定する必要があります。最新のSelenium libraryをお使いになることをお勧めします。 geckodriverhereからダウンロードできます。

FirefoxDriverオブジェクトを初期化する前に、関連するシステムプロパティを設定する必要があります。あなたは次のようにそれを行うことができます:

System.setProperty("webdriver.gecko.driver", "<path_to_geckodriver.exe>"); 
WebDriver driver = new FirefoxDriver(); 

さらなる質問があれば教えてください。

関連する問題