Selenium Python - How to deal with accidental ascent?

Over the past few months, I have used Selenium to automate a very boring but important part of my work, which includes loading forms.

Recently, the site has implemented a feedback survey, which accidentally pops up and switches the driver to a new frame. I wrote code that can handle this popup and switch back to my default frame, however, the problem is random.

Is there a way to run my pop-up handling code as soon as an exception is thrown generated by the wrong frame?

I could wrap my entire script in a block tryand except, but how can I direct the script to backup from where it left off?

Any advice is greatly appreciated!

+4
source share
2 answers

I came across this on the sites I'm working on. What I found on our site is that it is not random, it is a timer. Thus, basically, how it works, the client comes to the site. If they were not prompted to register for X, they get a popup. If they signed up or rejected the pop-up, the cookie records the tracking that they have already received the message. You want to find this tracking cookie and recreate it to prevent pop-ups.

, , cookie, ​​ ( example.com/some404page), script . .

, , ( - ) . , . . , , .

cookie, cookie . ( ). Chrome, , . , .

  • devtools (F12)
  • "" "" ( ).
  • cookie , . cookie , .
  • " ", cookie.
  • cookie. , cookie.
  • cookie 15 ( - ) , .

, , , , , . , cookie Selenium, "", example.com/some404page cookie. script. .

+1

.

- , script , .

script, selenium (, JavascriptExecutor), -, .

0

Source: https://habr.com/ru/post/1687584/


All Articles