提交 a959a180 authored 作者: 黄承天's avatar 黄承天

[fix]

下拉框操作改用Select类实现
上级 2896f471
......@@ -12,6 +12,7 @@ import com.zjty.autotest.websocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -251,7 +252,10 @@ public class SeleniumExecutor {
content = format("下拉框选择:[%s]", label);
element = locateElement(target);
if (nonNull(element)) {
element.findElement(By.xpath(format("//option[. = '%s']", label))).click();
// WebElement select = element.findElement(By.xpath(format("//option[. = '%s']", label)));
// select.click();
Select select = new Select(element);
select.selectByVisibleText(label);
costTime = System.currentTimeMillis() - stepStartTime;
success = true;
seleniumHelper.waitSomeTime();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论