iframe name="_ifrm" id="_ifrm" src="/air/wfw/html/iframe/about.html" title="_ifrm" height="368px" width="800" style="border:0;overflow- y:auto;overflow-x:hidden;" scrolling="no" frameborder="0" allowtransparency="true"> div class="k1_yb_pop_wrap" style="width: 800px; background-color: rgb(255, 255, 255);"> class="k1_tac" button class="k1_yb_btn k1_yb_btn_black k1_yb_btn_large" type="button" onclick="airfn_confirm_1100100016('Y')" accept a class="close_pop" onclick="airfn_confirm_1100100016('N')"> closed
我尝试使用以下代码关闭弹出窗口:
driver.switchTo().frame(Common.driver.findElement(By.xpath("//*[@id=\"_ifrm\"]"))); driver.findElement(By.xpath("/html/body/div[1]/div/p[2]/button")).click() ;
但是,错误测试是,
unknown error: Element <iframe name="_ifrm" id="_ifrm"
src="/air/wfw/html/iframe/about.html" title="_ifrm" height="368px"
width="800" style="border:0;overflow-y:auto;overflow-x:hidden;"
scrolling="no" frameborder="0" allowtransparency="true"
cd_frame_id_="01a42b9f9d1324c7bbec7a74e48a673b"></iframe> is not
clickable at point (591, 390). Other element would receive the click:
<div class="list_loading">...</div>(..)`enter code here`
答案 0 :(得分:0)
某些叠加层阻止与帧进行交互。您可能需要等到覆盖或加载器离开屏幕或页面。您可以尝试以下代码,它可能会对您有所帮助。
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("list_loading")));
driver.switchTo().frame(Common.driver.findElement(By.xpath("//*[@id=\"_ifrm\"]")));
driver.findElement(By.xpath("/html/body/div[1]/div/p[2]/button")).click() ;