Unable to interact with popup boxes using Python/Selenium web driver

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to interact with popup boxes using Python/Selenium web driver

Ranjana Palanivel

Hi All,

I am writing the python/selenium script to automate web page.I am struck in a place wherein the popup appears,after clicking on 'OK' in the popup ,control should transfer back to web page.

I have tried with  below script.But still I am not able to proceed .Please help me out on this.
Can anyone please help me out on this.
def is_alert_present(self):
try:
self.driver.switch_to_alert()
self.assertEquals("Channel Created Succesfully")
except NoAlertPresentException as e:
return False

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
assert "Channel Created Succesfully." in alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert.text
finally: self.accept_next_alert = True

def tearDown(self):
self.assertEqual([], self.verificationErrors)


--
Thanks & Regards

Ranjana P

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANS_8%3DuayNH4Wo4iAofVDXbzaxm8%3DqC6mpkdxv2pSOMY7ms4ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Ranjana Palanivel
In addition to this ,switch_to_alert() function is getting striked out in my python script as soon as i use it in my Pycharm editor.
What could be the reason for this?
I am importing below two modules in my script
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import NoSuchElementException




On Wed, May 16, 2018 at 7:19 AM, Ranjana Palanivel <[hidden email]> wrote:

Hi All,

I am writing the python/selenium script to automate web page.I am struck in a place wherein the popup appears,after clicking on 'OK' in the popup ,control should transfer back to web page.

I have tried with  below script.But still I am not able to proceed .Please help me out on this.
Can anyone please help me out on this.
def is_alert_present(self):
try:
self.driver.switch_to_alert()
self.assertEquals("Channel Created Succesfully")
except NoAlertPresentException as e:
return False

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
assert "Channel Created Succesfully." in alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert.text
finally: self.accept_next_alert = True

def tearDown(self):
self.assertEqual([], self.verificationErrors)


--
Thanks & Regards

Ranjana P



--
Thanks & Regards

Ranjana P

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANS_8%3Dv04t0A4-HNc5zAW5HWOBecf6_hbgqbxuJJVaapF_xi7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Reed Xia
Hi Ranjana,

Not sure whether this answer in stakoverflow https://stackoverflow.com/questions/33466853/switch-to-alert-text-not-working?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa can help you, which said you may need wait for the Alert to be present first before using switch_to_alert().

Thanks,
Reed

On Wed, May 16, 2018 at 10:07 AM, Ranjana Palanivel <[hidden email]> wrote:
In addition to this ,switch_to_alert() function is getting striked out in my python script as soon as i use it in my Pycharm editor.
What could be the reason for this?
I am importing below two modules in my script
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import NoSuchElementException




On Wed, May 16, 2018 at 7:19 AM, Ranjana Palanivel <[hidden email]> wrote:

Hi All,

I am writing the python/selenium script to automate web page.I am struck in a place wherein the popup appears,after clicking on 'OK' in the popup ,control should transfer back to web page.

I have tried with  below script.But still I am not able to proceed .Please help me out on this.
Can anyone please help me out on this.
def is_alert_present(self):
try:
self.driver.switch_to_alert()
self.assertEquals("Channel Created Succesfully")
except NoAlertPresentException as e:
return False

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
assert "Channel Created Succesfully." in alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert.text
finally: self.accept_next_alert = True

def tearDown(self):
self.assertEqual([], self.verificationErrors)


--
Thanks & Regards

Ranjana P



--
Thanks & Regards

Ranjana P

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANS_8%3Dv04t0A4-HNc5zAW5HWOBecf6_hbgqbxuJJVaapF_xi7g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAB_-H09oBuB4NgmBT1AvSVW7OFQ%2Bp2DQvQ8Jd8SF1hyS%3D3njrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Reed Xia
And in my project, we usually code it in this way, just FYI

WAITER = new WebDriverWait();
try {
  WAITER.until(ExpectedConditions.visibilityOfElementLocated(BY_ID_ELEMENT)); // a instanc of BY
  // do something next..
} catch (Exception e) {
 // handle the exception..
}

  

On Wed, May 16, 2018 at 11:06 AM, Reed Xia <[hidden email]> wrote:
Hi Ranjana,

Not sure whether this answer in stakoverflow https://stackoverflow.com/questions/33466853/switch-to-alert-text-not-working?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa can help you, which said you may need wait for the Alert to be present first before using switch_to_alert().

Thanks,
Reed

On Wed, May 16, 2018 at 10:07 AM, Ranjana Palanivel <[hidden email]> wrote:
In addition to this ,switch_to_alert() function is getting striked out in my python script as soon as i use it in my Pycharm editor.
What could be the reason for this?
I am importing below two modules in my script
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import NoSuchElementException




On Wed, May 16, 2018 at 7:19 AM, Ranjana Palanivel <[hidden email]> wrote:

Hi All,

I am writing the python/selenium script to automate web page.I am struck in a place wherein the popup appears,after clicking on 'OK' in the popup ,control should transfer back to web page.

I have tried with  below script.But still I am not able to proceed .Please help me out on this.
Can anyone please help me out on this.
def is_alert_present(self):
try:
self.driver.switch_to_alert()
self.assertEquals("Channel Created Succesfully")
except NoAlertPresentException as e:
return False

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
assert "Channel Created Succesfully." in alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert.text
finally: self.accept_next_alert = True

def tearDown(self):
self.assertEqual([], self.verificationErrors)


--
Thanks & Regards

Ranjana P



--
Thanks & Regards

Ranjana P

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANS_8%3Dv04t0A4-HNc5zAW5HWOBecf6_hbgqbxuJJVaapF_xi7g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAB_-H09ButxA%2BACB5OvQQwBE-qSUU%3DyeKJ%3Dx6tS1uVFSyoQShw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Wayne
Way to go.

On Tue, May 15, 2018 at 11:12 PM, Reed Xia <[hidden email]> wrote:
And in my project, we usually code it in this way, just FYI

WAITER = new WebDriverWait();
try {
  WAITER.until(ExpectedConditions.visibilityOfElementLocated(BY_ID_ELEMENT)); // a instanc of BY
  // do something next..
} catch (Exception e) {
 // handle the exception..
}

  

On Wed, May 16, 2018 at 11:06 AM, Reed Xia <[hidden email]> wrote:
Hi Ranjana,

Not sure whether this answer in stakoverflow https://stackoverflow.com/questions/33466853/switch-to-alert-text-not-working?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa can help you, which said you may need wait for the Alert to be present first before using switch_to_alert().

Thanks,
Reed

On Wed, May 16, 2018 at 10:07 AM, Ranjana Palanivel <[hidden email]> wrote:
In addition to this ,switch_to_alert() function is getting striked out in my python script as soon as i use it in my Pycharm editor.
What could be the reason for this?
I am importing below two modules in my script
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import NoSuchElementException




On Wed, May 16, 2018 at 7:19 AM, Ranjana Palanivel <[hidden email]> wrote:

Hi All,

I am writing the python/selenium script to automate web page.I am struck in a place wherein the popup appears,after clicking on 'OK' in the popup ,control should transfer back to web page.

I have tried with  below script.But still I am not able to proceed .Please help me out on this.
Can anyone please help me out on this.
def is_alert_present(self):
try:
self.driver.switch_to_alert()
self.assertEquals("Channel Created Succesfully")
except NoAlertPresentException as e:
return False

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
assert "Channel Created Succesfully." in alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert.text
finally: self.accept_next_alert = True

def tearDown(self):
self.assertEqual([], self.verificationErrors)


--
Thanks & Regards

Ranjana P



--
Thanks & Regards

Ranjana P

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANS_8%3Dv04t0A4-HNc5zAW5HWOBecf6_hbgqbxuJJVaapF_xi7g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAB_-H09ButxA%2BACB5OvQQwBE-qSUU%3DyeKJ%3Dx6tS1uVFSyoQShw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAE4iJQ3QyXh1T8XVV79R7oobQvdMfBsQU-uNg8u%2B%2BwpzkZODNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Ranjana Palanivel
In reply to this post by Reed Xia
thanks for the solution..i hv used web driverwait .. i am able to proceed now.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cf01b3e7-f9da-4ee6-8d27-80c97064ec12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to interact with popup boxes using Python/Selenium web driver

Rakesh Raut
HI Ranjana,

Try using below code instead of wait.
driver.switch_to.default_content()

On Wednesday, May 16, 2018 at 11:28:25 AM UTC-4, Ranjana Palanivel wrote:
thanks for the solution..i hv used web driverwait .. i am able to proceed now.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/dc67d62c-c5ae-46e8-a3df-56c9f6f11184%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.