I have been trying to automate facebook searching using python selenium but I don't know how to allow or block the pop ups, I have provided a picture below, that might help you understand the problem better
https://i.stack.imgur.com/V1ABR.png
This is the code, and I don't know what I have imported but it still works though :-)
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
driver = webdriver.Chrome()
facebook_URL = ('https://www.facebook.com/')
twitter_URL = ('https://www.twitter.com/')
def facebook():
driver.get(facebook_URL) # To open the browser and search for facebook
time.sleep(2)
# It finds the Input box for the email
emailFace = driver.find_element_by_xpath('//*[@id="email"]')
# This inputs the the text which we want to
emailFace.send_keys('hello@gmail.com')
passFace = driver.find_element_by_xpath('//*[@id="pass"]')
passFace.send_keys('check1234')
loginFace = driver.find_element_by_xpath('//*[@id="u_0_b"]')
loginFace.click()
def twitter():
driver.get(twitter_URL) # To open the browser and search for facebook
time.sleep(2)
logIn = driver.find_element_by_xpath(
'//*[@id="react-root"]/div/div/div/main/div/div/div/div[1]/div/a[2]')
logIn.click()
# It finds the Input box for the email
emailTwitt = driver.find_element_by_xpath(
'//*[@id="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[1]/label/div/div[2]/div/input')
# This inputs the the text which we want to
emailTwitt.send_keys('hello@gmail.com')
passTwitt = driver.find_element_by_xpath(
'//*[@id="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[2]/label/div/div[2]/div/input')
passTwitt.send_keys('check1234')
loginTwitt = driver.find_element_by_xpath(
'//*[@id="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[3]/div')
loginTwitt.click()
facebook()