![]() |
selenium bypass javascript popup box - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: selenium bypass javascript popup box (/thread-3550.html) |
selenium bypass javascript popup box - metulburr - Jun-02-2017 I am trying to list out my facebook membership groups using selenium, but i cant without bypassing this javascript box. The [attachment=189] attempting to proceed without taking care of this box causes Then i added the browser.switch_to_alert().accept() but now i get a no alert open error
r = browser.get('https://www.facebook.com/groups/?category=groups') time.sleep(DELAY) alert = browser.switch_to_alert() alert.accept() for _ in range(100): #scroll to make all groups visible browser.execute_script("window.scrollTo(0, document.body.scrollHeight);") soup = BeautifulSoup(r.page_source, 'lxml') print(soup.find("div", {"id": "group-discover-card-right-columnmembership"}))Usually i would just find the XPath to the submit/ok button and select it but with the method i dont think you can see the source of this. RE: selenium bypass javascript popup box - buran - Jun-02-2017 would blocking push notifications (at least temporary) be OK? https://support.google.com/chrome/answer/3220216?co=GENIE.Platform%3DDesktop&hl=en RE: selenium bypass javascript popup box - Larz60+ - Jun-02-2017 Can you use expect to answer the required input automatically? RE: selenium bypass javascript popup box - metulburr - Jun-02-2017 well i plan on using phantomjs afterwords. Im just using chrome to see what the html is at the time the script executes. I have tried manually allow/block, but the following execution it comes back every time. RE: selenium bypass javascript popup box - snippsat - Jun-02-2017 Not sure if if look upon as alert. Then you have to switch window and probably in combo with window_handles .driver.switch_to.window(window_name) Something like this should get the latest open window. driver.switch_to_window(driver.window_handles[-1])
RE: selenium bypass javascript popup box - metulburr - Jun-02-2017 Doesnt switch to window create a new tab basically? I tried loading a new page, but the javascript popup shows on any page loaded to facebook RE: selenium bypass javascript popup box - snippsat - Jun-02-2017 (Jun-02-2017, 05:52 PM)metulburr Wrote: Doesnt switch to window create a new tab basically?It can also handle a pop up window,which it's not an alert. Now do it look like an alert,so what you have done should work. Here some alert test. |