我想在此灯箱中选择确认按钮,然后通过selenium点击它。我该如何选择呢?我通过nodejs使用selenium。 display属性最初没有。当我们单击一个按钮时,它会变为阻止。弹出窗口的HTML如下所示。
<div class="app-popup confirm-popup" style="display: block;">
<section aria-describedby="modal-content-id-1" aria-labelledby="modal-heading-01" class="slds-modal slds-fade-in-open" role="dialog" tabindex="-1">
<div class="slds-modal__container">
<header class="slds-modal__header">
<a class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" onclick="APP.VIEW.closePopup(event);" title="Close">
<svg aria-hidden="true" class="slds-button__icon slds-button__icon_large"><use xlink:href="/resource/1508374553000/slds/assets/icons/utility-sprite/svg/symbols.svg#close" xmlns:xlink="http://www.w3.org/1999/xlink"></use></svg>
<span class="slds-assistive-text">Close</span>
</a>
<h2 class="slds-text-heading_medium slds-hyphenate question-title">Negotiation Complete</h2>
</header>
<div class="slds-modal__content slds-p-around_medium question-container">
<p class="question">Are you sure?</p>
</div>
<footer class="slds-modal__footer">
<a class="slds-button slds-button_neutral" href="#" onclick="APP.VIEW.closePopup(event)"><i aria-hidden="true" class="fa fa-times"></i> Cancel</a>
<a class="slds-button slds-button_brand confirm-button" href="#" onclick="APP.UTIL.getPopupWindow('0660a000000Ep3V').APP.VIEW.performBusinessAction(event, 'NegotiationComplete', 'Negotiation Complete', false)"><i aria-hidden="true" class="fa fa-check"></i> Confirm</a>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</div>
直到现在我已经尝试过这个:
driver.wait(until.elementIsVisible(driver.findElement(By.xpath('//*[@id="j_id0:j_id3:j_id4"]/div[3]/div[2]')))).then(() => {
driver.wait(until.elementLocated(By.xpath(jsonData[index].selector))).click().then(() => {
console.log(jsonData[index].label + " Clicked");
index++;
legal(jsonData, index);
})
})
第一个xpath是整个div的路径。第二个xpath是Confirm按钮。
但是在运行代码时,它说它无法找到xpath本身。任何解决方案吗?