无法吸引iframe

时间:2019-04-30 12:16:25

标签: java selenium

Image在保存记录时,如何处理弹出的窗口?我尝试了Actions类,robot类但似乎无济于事。

    <div tabindex="-1" role="dialog" class="ui-dialog ui-corner-all ui-widget 
    ui-widget-content ui-front critical-dialog ui-dialog-buttons" aria- 
    describedby="ui-id-7" aria-labelledby="ui-id-8" style="height: auto; 
    width: 
    300px; top: 302.005px; left: 611.48px;"><div class="ui-dialog-titlebar ui- 
    corner-all ui-widget-header ui-helper-clearfix"><span id="ui-id-8" 
    class="ui-dialog-title">&nbsp;</span><button type="button" class="ui- 
    dialog-titlebar-close fa fa-close"></button></div><div id="ui-id-7" 
    class="ui-dialog-content ui-widget-content" style="z-index: 3000000; 
    width: auto; min-height: 28.86px; max-height: none; height: auto;"><div 
    class="title"></div><div class="message">Search updated successfully! 
    </div></div><div class="ui-dialog-buttonpane ui-widget-content ui-helper- 
    clearfix"><div class="ui-dialog-buttonset"><button 
    type="button">OK</button></div></div></div>

and 
    <iframe tabindex="-1" aria-hidden="true" role="presentation" 
    title="Intentionally blank" name="lpSS_38260369681" id="lpSS_38260369681" 
    src="https://lpcdn.lpsnmedia.net/le_secure_storage/3.7.0.1- 
    release_442/storage.secure.min.html? 
    loc=https%3A%2F%2Fqa.criticalmention.com&amp;site=10551349&amp;env=prod" 
    style="width: 0px; height: 0px; position: absolute; top: -1000px; left: 
    -1000px; display: none;"></iframe>

1 个答案:

答案 0 :(得分:1)

在与iframe中的元素进行交互之前,您需要切换到该元素:

driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[title='Intentionally blank']")));