Reputation: 153
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")
Upvotes: 1
Views: 579
Reputation: 153
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)
Upvotes: 2