1

I am writing a python script using selenium to login to Facebook and then do some scrapping. For that purpose, I have to scroll down to the bottom of the page. I think the pop that you can see in the picture is the cause of this. Here is the snippet of code which does the following thing

elem = driver.find_element_by_id("email")
elem.send_keys(usr)
elem = driver.find_element_by_id("pass")
elem.send_keys(pwd)
elem.send_keys(Keys.RETURN)

driver.get("https://www.facebook.com/jatin.wadhwa.52/friends?source_ref=pb_friends_tl")
time.sleep(10)

element_new = driver.find_element_by_tag_name('html')
element_new.send_keys(Keys.ESCAPE)
element_new.send_keys(Keys.END)

#driver.execute_script("window.scrollTo(0, 1000);")
f = driver.find_elements_by_xpath("//ul")

Picture of Pop up on browser

1
  • Don't try to scrape Facebook. You will be blocked sooner or later. Just use the API Commented Oct 11, 2016 at 2:10

1 Answer 1

2

Solved.

Adding this will resolve and woulndt allow any such pop ups.

    chrome_options = webdriver.ChromeOptions()
    prefs = {"profile.default_content_setting_values.notifications" : 2}
    chrome_options.add_experimental_option("prefs",prefs)
    #driver = webdriver.Chrome(chrome_options=chrome_options)

driver = webdriver.Chrome(r"C:\Users\jatin\Downloads\chromedriver_win32\chromedriver.exe",chrome_options=chrome_options)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.