【发布时间】:2017-12-05 13:11:10
【问题描述】:
我有一个网页,其中有一个特定股票是否开盘/收盘的指标。 为此,我想设置一个 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' 下出现语法错误:
标记“else”的语法错误,删除此标记
【问题讨论】:
-
你有一个多余的
;。
标签: java selenium if-statement selenium-webdriver elements