gpt4 book ai didi

java - 选择动态保管箱

转载 作者:行者123 更新时间:2023-11-29 04:16:59 25 4
gpt4 key购买 nike

我在网站:https://www.mister-auto.com/在“En sélectionnant mon véhicule”部分,我想选择品牌“Peugeot”、型号“107 [06/2005”和汽车的发动机“1.0 (68Cv)”,我尝试了这个品牌但没有工作:

Select option = new Select(driver.findElement(By.xpath("/div[@class='dropdown'][1]/select[@class='form-control col-xs-12 ng-pristine ng-valid ng-not-empty ng-touched']")));
option.selectByVisibleText("Peugeot");

知道为什么吗?

干杯。

最佳答案

这应该有效:

WebElement element=driver.findElement(By.xpath("//select[@ng-model='brand_id']"));
Select option=new Select(element);
option.selectByValue("88");

现在,如果您必须在 Peugeout 的后续下拉列表中单击模型 1007,则需要使用如下所示的 JavascriptExecutor。这是因为它是一个 optgroup 元素,而 optgroup 的 Select 类中还没有任何内容。

WebElement element2=driver.findElement(By.xpath("//select[@ng-model='model_id']"));
element2.click();
WebElement element1=driver.findElement(By.xpath("//select[@ng-model='model_id']/optgroup[contains(@label,'1007')]"));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", element1);

关于java - 选择动态保管箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51729234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com