在其他方面,它的节目"Syntax error on token "其他", delete this token"



这是我应用程序的源代码。我不明白为什么这会在 else 关键字上出错。

public static void main(String[] args) {
    WebDriver driver = new FirefoxDriver();// Launches Firefox browser with blank url
    driver.get("http://www.gcrit.com/build3/admin/login.php");
    driver.findElement(By.name("username")).sendKeys("admin");
    driver.findElement(By.name("password")).sendKeys("admin@123");
    driver.findElement(By.id("tdb1")).click();
    String url = driver.getCurrentUrl();
    if(url.equals("http://www.gcrit.com/build3/admin/index.php"));
    {
        System.out.println("LOgin Successful--PASS");
    }
    else
    {
        System.out.println("Login Unsuccessful--FAIL");
    }
    driver.close();// Closes the browser
}

删除 if(url.equals("http://www.gcrit.com/build3/admin/index.php")); 中的;。所以你的代码应该是 - if(url.equals("http://www.gcrit.com/build3/admin/index.php"))

您应该删除包含 if 语句的行末尾的分号。

public static void main(String[] args) {
    WebDriver driver = new FirefoxDriver();// Launches Firefox browser with blank url
    driver.get("http://www.gcrit.com/build3/admin/login.php");
    driver.findElement(By.name("username")).sendKeys("admin");
    driver.findElement(By.name("password")).sendKeys("admin@123");
    driver.findElement(By.id("tdb1")).click();
    String url = driver.getCurrentUrl();
    if(url.equals("http://www.gcrit.com/build3/admin/index.php"))
    {
        System.out.println("LOgin Successful--PASS");
    }
    else
    {
         System.out.println("Login Unsuccessful--FAIL");
    }
    driver.close();// Closes the browser
 }

相关内容