Share
Go down
anita.totad88
Posts : 8
Join date : 2012-05-25

selenium-Webdriver

on Fri May 25, 2012 3:59 pm
Hi All,

The problem I am facing here that actually i need to click on alert message dialog "Ok"
the code is here
"span class="jsx30button_text" style="position: relative; display: inline-block; height: 12px;" jsxtabindex="0" tabindex="0">Delete "/span"

but i tried with following commands:
//span[@class='jsx30button_text']
but it did not work.
could you please help on this
avatar
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 31
Location : INDIA
http://radical-qa.blogspot.in/

Re: selenium-Webdriver

on Fri May 25, 2012 4:31 pm
As alert is java-script generated, n you are using webdriver..Use below command
Code:
IAlert alert = driver.SwitchTo().Alert();
string alertText = alert.Text;// Get the text
alert.Accept();// Accept

_________________
Radical QA
http://radical-qa.blogspot.in/
anita.totad88
Posts : 8
Join date : 2012-05-25

Re: selenium-Webdriver

on Fri May 25, 2012 5:10 pm

it didn't work..
Arahant
Active particpant
Active particpant
Posts : 23
Join date : 2012-02-29

Re: selenium-Webdriver

on Mon May 28, 2012 12:22 pm
Try with following steps.

1) After click on web element which is going to popup alert dialog.
2) Then use this code.

drive.switchTo().alert().accept();

Hope will work..
ashish_techie
Amateur
Amateur
Posts : 73
Join date : 2011-08-09

Re: selenium-Webdriver

on Tue May 29, 2012 2:23 pm
YES, YOU CAN USE THIS CODE

drive.switchTo().alert().accept();

OR

Alert alert = driver.switchTo().alert();
// alert.accept(); - to click OK
// alert.dismiss(); - to click cancel

it will work if it is a Alert. To check this you can see the page source.


regards
Ashish Thakur

For selenium training visit www.qtpselenium.com/selenium-training



Sponsored content

Re: selenium-Webdriver

Back to top
Permissions in this forum:
You cannot reply to topics in this forum