关于我遇到的问题,我只是有一个足够简单的问题。我试图设置一个字符串值,"0"如果一个 webelement 不存在,否则字符串是 webelement 值(使用getText)。但是,我似乎无法在if 和 else语句之外使用这些值。我该怎么做呢?
这是我的代码
String players_in_game = null;
public void join_game_user_increases_register() throws Exception {
WebDriverWait wait = new WebDriverWait(Drivers.getDriver(), 10);
wait.until(ExpectedConditions.visibilityOf(countdownLabel));
if (!num_of_players_in_game.isDisplayed()) {
String players_in_game = "0";
} else {
String players_in_game = num_of_players_in_game.getText();
}
System.out.println(players_in_game);
int first_num = Integer.parseInt(players_in_game);
开心每一天1111
梦里花落0921
万千封印
相关分类