[英]Using Selenium Alert Handler in VBA with Chrome
I've placed a serial number in a box and clicked the button, and a popup alert appears saying that serial number is not found, OK to continue.我已将序列号放入一个框中并单击按钮,然后会出现一个弹出警报,提示未找到序列号,确定以继续。
TagSerialBox.Clear ' Clear the default text already in the box
On Error GoTo AlertHandler ' Go here if serial number not found
TagSerialBox.SendKeys serial ' Enter the serial number into the box
Dim ClickPreview As selenium.WebElement ' This is the item displayed
Set ClickPreview = Partssite.FindElementById("fetchlink") ' Focus on the link
ClickPreview.Click ' Click the link
AlertHandler:
MsgBox "Serial# " & serial & " not found, need to re-enter"
driver.SwitchToAlert().Accept ' Should send OK to the alert popup and continue.
This code works fine when the serial number is found, but when it isn't found, it goes to the Alert Handler as expected and当找到序列号时,这段代码工作正常,但当找不到时,它会按预期进入警报处理程序,
[https://www.guru99.com/alert-popup-handling-selenium.html][1] Might give you hints what the issue is. [https://www.guru99.com/alert-popup-handling-selenium.html][1] 可能会给您提示问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.