在模态弹出窗口中找不到Selenium webdriver元素

问题描述 投票:0回答:1

HTML:

button type="button" class="btn btn-primary" onclick="document.getElementById('formChangePIN').submit();">Submit</button

码:

wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[class='btn btn-primary']"))).click();

而此代码在运行时工作

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\\\"blockCardModal\\\"]/div/div/div[3]/button[2]"))).click();
selenium-webdriver
1个回答
0
投票

尝试使用窗口句柄在窗口之间切换并执行单击操作

或使用动作驱动程序单击

WebElement element = driver.findElement(locator)
actions.moveToElement(element).click().perform();
© www.soinside.com 2019 - 2024. All rights reserved.