How to close the browser by rejecting popup window in selenium webdriver

后端 未结 1 1303
野的像风
野的像风 2021-01-24 02:02

I have one test case where after login, on some page when user tries to close the browser, it will show popup windows(alert) asking \"you might lose the data, are you sure you w

相关标签:
1条回答
  • 2021-01-24 02:16

    If I am understanding the problem correctly, then you are trying to perform a click on X to close the browser window which generates additional pop up. If that's the case, you can try executing some JavaScript action to recreate the scenario

    (( JavascriptExecutor ) webdriver).executeScript( "window.close()" );
    

    instead of webdriver.close()

    Note: Written in Java

    More info: With the syntax above you can only close the child tab not the entire browser only IF it is invoked with window.open()

    0 讨论(0)
提交回复
热议问题