gpt4 book ai didi

java - 无法使用 Selenium WebDriver 单击
创建的下拉菜单

转载 作者:行者123 更新时间:2023-12-01 09:30:14 24 4
gpt4 key购买 nike

HTML 代码

<div qxselectable="off" >
<div qxselectable="off" >
<div tabindex="1" qxselectable="off" >
<div tabindex="1" qxselectable="off" >
<div style="overflow: hidden; >Discrepancy Type*</div>
<div class="qx-input-required" tabindex="7" ">
<input class="qx-abstract-field qx-placeholder-color" >
//On Below button there is one dropdown button on which i want to click but i cannot
<div class="qx-button" qxselectable="off" >
<div qxselectable="off" qxanonymous="true" ></div>
</div>
</div>
</div>
<div tabindex="1" qxselectable="off" >
</div>
</div>
<div class="qx-outSet" qxse..

Java 代码

WebElement element = wd.findElement(By.className("qx-input-required"));
Actions actions = new Actions(wd);
actions.moveToElement(element).click().perform();
wd.findElement(By.xpath(".//*[@id='demindoRoot']/div[3]/div[2]/div[1]/div/div[2]/div[2]/div/div")).click(); // link through which i try to click
Thread.sleep(1000);

我也尝试过下面提到的代码

wd.findElement(By.xpath("//div[@class='qx-button'"));

enter image description here

错误:

Unable to locate element:

最佳答案

action.moveToElement(element).moveToElement(driver.findElement(By.Xpath(<Your path here>))).click().build().perform();

这更像用户执行的操作。用户首先导航到菜单,打开它,然后导航到他们想要单击的元素。查看此问题以了解更多详细信息: https://stackoverflow.com/a/17294390/3537915

关于java - 无法使用 Selenium WebDriver 单击 <div> 创建的下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39490277/

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