我有一个网页,其中包含特定股票是否开仓/平仓的指示器。 为此,我想设置一个 if & else if 语句。由于某种原因,我在 eclipse 中遇到错误。
*注意:不知道它是否有帮助,但是如果我将代码复制/粘贴到一个新的空类(即“主”类)中,它就可以正常工作,不会出现任何错误 - 所以代码的结构是好的我猜测。
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class TestClock {
public static void chromeMethod(WebDriver driver) {
System.setProperty("webdriver.chrome.driver", "C:\\automation\\drivers\\chromedriver.exe");
}
public static void runTestClock(WebDriver driver)
{
WebElement Status = null;
if( Status == driver.findElement(By.cssSelector(".redClockBigIcon")));
{
System.out.println("Stock is closed");
driver.navigate().back();
}
else if (Status == driver.findElement(By.cssSelector(".greenClockBigIcon")) );
{
System.out.println("Stock is open");
driver.navigate().back();
}
}
}
我在“else”下遇到语法错误:
Syntax error on token "else", delete this token
最佳答案
else if (Status == driver.findElement(By.cssSelector(".greenClockBigIcon")) );
这是你的错误:最后一个;必须删除
关于java - Selenium WD/Java |无法创建 'if' 和 'else if' 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654497/