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

时间:2018-03-06 08:55:16

标签: selenium-webdriver

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();

1 个答案:

答案 0 :(得分:0)

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

或使用动作驱动程序单击

for i in range(3):
  # Gives coords from all sources
  msg = dBusInterface.call('getCoordinates', i) 
  reply = QDBusReply(msg)
  ...