현재 Selenium 튜토리얼 Here을 사용하고 있으며 모든 단계를 정확하게 따라했지만 Eclipse 프로그램에서 오류가 계속 발생합니다. 이 튜토리얼은 이전 버전 용이지만 Selenium 3을 사용하고 있습니다. 이 튜토리얼을 제외하고는 포괄적 인 튜토리얼을 찾을 수 없습니다. 다음 코드에서 오류를 수정하려면 어떻게합니까? 나는 각 줄 이후에 얻은 정확한 오류에 대해 논평했다. 코드에는 이미 몇 개의 주석이 포함되어 있으므로 라인 시작 부분의 주석을 무시하십시오. 다른 모든 것은 오류 메시지 여야합니다.Selenium 튜토리얼 문제, 내가받는 오류를 어떻게 수정합니까?
Eclipse를 사용하여 클래스 경로를 설정하는 방법을 알아야하며 GeckoDriver에 액세스 할 수 있도록 허용해야합니다. GeckoDriver는이 문제를 해결할 수도 있고 그렇지 않을 수도 있습니다.
public class Gmail_Login { //Syntax error on token(s), misplaced construct(s)
import org.openqa.selenium.By; //The import org.openqa.selenium.By cannot be resolved
import org.openqa.selenium.WebDriver; // The import org.openqa.selenium.WebDriver cannot be resolved
import org.openqa.selenium.WebElement;// The import org.openqa.selenium.WebElement cannot be resolved
import org.openqa.selenium.firefox.FirefoxDriver;// The import org.openqa.selenium.firefox. cannot be resolved
/**
* @param args
*/
public static void main(String[] args) { //Multiple markers at this line -Syntax error,insert "enum Identifier" to complete EnumHeader -Syntax error on tokens, AnnotationName expected instead -Syntax error on token "}",invalid ( -Syntax error, insert")" to complete SingleMemberAnnotation -Syntax error, insert "]" to complete ArrayAccess
// objects and variables instantiation
WebDriver driver = new FirefoxDriver();//Multiple markers at this line -FirefoxDriver cannot be resolved to a type -WebDriver cannot be resolved to a type
String appUrl = "https://accounts.google.com";
// 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"));//Multiple markers at this line -WebElement cannot be resolved to a type
username.clear();
username.sendKeys("TestSelenium");
// enter a valid password in the password textbox
WebElement password = driver.findElement(By.id("Passwd")); //Multiple markers at this line -WebElement cannot be resolved to a type -By cannot be resolved -By cannot be resolved
password.clear();
password.sendKeys("password123");
// click on the Sign in button
WebElement SignInButton = driver.findElement(By.id("signIn")); //Multiple markers at this line -WebElement cannot be resolved to a type -By cannot be resolved
SignInButton.click();
// close the web browser
driver.close();
System.out.println("Test script executed successfully.");
// terminate the program
System.exit(0);
}
}//Syntax error on token "}", delete this token
수업 외부로 가져 오지 않습니까? 자습서 에서처럼 다음과 같이 하시겠습니까? 또한, Selenium의 다른 버전을 목표로하기 때문에 모든 것이 동일하다고 무작위로 추측 할 수는 없습니다. –
셀레늄 3는 아주 새로운 제품입니다. (5 일 전에 출시되었습니다). 철저한 튜토리얼이 아직 Selenium 3을 위해 작성되지 않았다고 확신 할 수 있습니다. – sircapsalot
@DaveNewton 클래스 외부에 놓아도 동일한 오류가 모두 반환됩니다. 나는 그것들을 scope로 나중에 참조하기 쉽도록 클래스 밖에서 정의/가져 오기를 원한다고 생각했다. 셀레늄도 그 능력을 가지고 있는지 모르겠습니다. –