Eclipseとキュウリを使ってセレンのwebdriverを使って作業を自動化しようとしています。私の機能ファイルを実行中に下記見ることができるように私は私のTests_Steps.javaクラスで私が正しく変数「ドライバ」を宣言した、変数が定義されていても変数を特定できません
java.lang.Error: Unresolved compilation problem: driver cannot be resolved
を以下のエラーを取得しています。また、オブジェクトをクラスのインスタンス(FirefoxDriver)に割り当てました。以下は私のコードです。
package stepDefinition;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class Tests_Steps {
@Given("^User is on the Home Page$")
public void user_is_on_the_Home_Page() throws Throwable {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.get("http://www.gmail.com/login");
}
@When("^User Clicks on the Login$")
public void user_Clicks_on_the_Login() throws Throwable {
driver.findElement(By.xpath(".//*[@id='login']")).click();
}
@When("^User enters UserName and Password$")
public void user_enters_UserName_and_Password() throws Throwable {
driver.findElement(By.id("login")).sendKeys("ab24146_111");
driver.findElement(By.id("psw")).sendKeys("Password1");
driver.findElement(By.id("loginButton")).click();
}
@Then("^Message displayed LogIn Successfully$")
public void message_displayed_LogIn_Successfully() throws Throwable {
System.out.println("Login Successfully");
}
何らかの理由で、私のドライバ変数が2番目と3番目のステップで認識されません。私は赤い波状の線を見て、私は赤い線の上にマウスを置いたとき、それは "ドライバは解決することはできません"と言う最初のステップでは正常に動作します。
あなたは何をする必要があるか私を助けてもらえますか?
方法で定義された変数は唯一、そのメソッド内に存在するためであろうと。 – immibis
ありがとう!出来た!! –