开发者

how to make selenium to wait for few seconds after clicking a button

开发者 https://www.devze.com 2023-04-11 17:18 出处:网络
can anyone help in this issue:Im clickin a button, at the end of the case by this: selcmd.Click(objget3);

can anyone help in this issue: Im clickin a button, at the end of the case by this:

selcmd.Click(objget3);

after clicking this button the page suddenly closed but i have to see the results so it needs to wait for few sec ter.i used waitforpageload() below the code but no use. 开发者_Go百科how can i code it using selenium.

thanks chinnu


I don know which language you are usin, this is for python code. Try this it may help.

import time

time.sleep( 5 )


If the Click() closes the page, there's nothing you can do to stop that short of replacing window.close() with your own version that delays the closing.


You can try with defining some time to wait like :

selcmd.waitForPageToLoad("30000");

which will wait for 30 secs after clicking the button.


//// This is for writing in Java / JUint 4 ////

I've been looking around for a few days and found this. Created a test case in the IDE which paused for 5 seconds then exported it into JUint 4 and found the following technique.

First of all, make sure your method has 'throws Exception':

public void thisTest() throws Exception {
    // Test code here
}

Then you want to add this line to wait for 5 seconds:

Thread.sleep(5000);

The argument for the sleep method is in milliseconds.

Hope this is what you're looking for!


For .Net >>

//selenium mentioned below is the ISelenium object you used in your scripts

Solution 1:

selenium.SetSpeed("5000");

The above command will wait 5ms before executing the next command.

Solution 2:

You can prevent browser from closing after the 'Test' execution if you comment the [TearDown] function.(i.e comment the command selenium.Stop())

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号