Handling of robotframework+Selenium2Library modal window

Original link: https://www.cnblogs.com/zuola/p/5750018.html

 
The so-called modal window refers to the dialog box on which the user's mouse focus or input cursor will stay on unless an effective closing method is taken. (To put it bluntly, after the modal window pops up, the following window cannot be clicked)

There is a demo page here
http://www.robotframework.net/ ... alogA

 

For the new window Eg opened in window.showModalDialog() mode, click "Details" of "Payment Details", and a new page will appear. How to locate it? Simply selecting window title=payDetail page will not locate the new window. The solution is as follows:

In web automation testing, it may be encountered from time to time, but if the normal operation (click button) to open the modal window

will cause the RF to get stuck and not run. So you must use asynchronous js to open the modal window. The

core code is setTimeout(function(){document.getElementById("aa").click()},100).

The specific demo is as follows

dialog.png

 

Usually this is solved.

 

Sometimes when getElementById, the id of this element cannot be found at all, what should I do? ?

idea: Create a static id and assign an id element to the label

 

Give the new id to getElementById, as follows:

setTimeout(function(){document.getElementById("aa").click()},100)

 

 

Continue to think about it: Click element xxx is replaced by execute javascript document.getElementById('xxx').click() Basically, it is replaced by javascript execution, and it will pass easily. If the element does not have an ID, it needs to be positioned with css, and I use jquery to execute it. Execute javascript $("css").click().
The so-called modal window refers to the dialog box on which the user's mouse focus or input cursor will stay on unless an effective closing method is taken. (To put it bluntly, after the modal window pops up, the following window cannot be clicked)

There is a demo page here
http://www.robotframework.net/ ... alogA

 

For the new window Eg opened in window.showModalDialog() mode, click "Details" of "Payment Details", and a new page will appear. How to locate it? Simply selecting window title=payDetail page will not locate the new window. The solution is as follows:

In web automation testing, it may be encountered from time to time, but if the normal operation (click button) to open the modal window

will cause the RF to get stuck and not run. So you must use asynchronous js to open the modal window. The

core code is setTimeout(function(){document.getElementById("aa").click()},100).

The specific demo is as follows

dialog.png

 

Usually this is solved.

 

Sometimes when getElementById, the id of this element cannot be found at all, what should I do? ?

idea: Create a static id and assign an id element to the label

 

Give the new id to getElementById, as follows:

setTimeout(function(){document.getElementById("aa").click()},100)

 

 

Continue to think about it: Click element xxx is replaced by execute javascript document.getElementById('xxx').click() Basically, it is replaced by javascript execution, and it will pass easily. If the element does not have an ID, it needs to be positioned with css, and I use jquery to execute it. Execute javascript $("css").click().

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325286656&siteId=291194637