P
P
puszkin2018-12-17 19:41:38
Python
puszkin, 2018-12-17 19:41:38

How to find xpath selenium facebook add as friend button?

Interested in the top button "add to friends"5c17d163001cd683750747.jpeg

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

1 answer(s)
T
Talik, 2018-12-18
@Talik0507

by_css("div#pagelet_timeline_profile_actions button.FriendRequestAdd")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question