Answer the question
In order to leave comments, you need to log in
How to find xpath selenium facebook add as friend button?
Interested in the top button "add to friends"
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time,random
import traceback;#uotput error
from selenium.webdriver.common.action_chains import ActionChains
akki_url = 'https://www.facebook.com/profile.php?id=100000483633352'
#https://www.facebook.com/profile.php?id=100000480483979
driver = webdriver.Chrome()
#driver = webdriver.Firefox()
driver.get('https://www.facebook.com/')#.maximize_window()#.implicitly_wait(20)
driver.maximize_window()
#driver.manage().window().maximize();
#time.sleep(10)
element = driver.find_element_by_id("email") #находим поле с email
element.send_keys("****")#вводим значение
element = driver.find_element_by_id("pass") #находим поле с пароля
element.send_keys("****", Keys.ENTER)#вводим значение и нажимаем ентер
#time.sleep(5)
driver.get(akki_url)
#time.sleep(5)
driver.find_element_by_tag_name("body").send_keys('', Keys.ESCAPE)
t=driver.page_source
#time.sleep(5)
#driver.find_element_by_xpath('//button[@class="FriendRequestAdd"]/i')
driver.find_element_by_xpath('//button[@class="FriendRequestAdd"]')
#driver.find_element_by_xpath('//*[contains(concat(" ", @class, " "), "FriendRequestAdd"]')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question