I had a problem with Facebook share button when I execute that it's doing all good but it's not clicking on facebook share button please help me!
Here is my video you can see here>> https://photos.app.goo.gl/Pi1tRQTwhqg5tmpn9
here is element HTML code:
here is this element code :
<span class="_18vi"><a class=" _2nj7 _18vj _18vk" data-ft="{ "tn": "J", "type": 25 }" href="/ajax/sharer/?s=22&appid=25554907596&id=1816791348467451&p[0]=130584170421519&p[1]=1816792805133972&sharer_type=all_modes&av=130584170421519" rel="dialog" role="button" tabindex="0" title="Send this to friends or post it on your timeline.">Share</a></span>
Here is my code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get("https://www.facebook.com/")
driver.maximize_window()
phone=WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='email']"))).send_keys("03460522942")
time.sleep(2)
pas=WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='pass']"))).send_keys("......")
time.sleep(.5)
login=WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='loginbutton']"))).click()
time.sleep(.5)
#Searc
search=WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.XPATH, "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/form[1]/div[1]/div[1]/div[1]/div[1]/input[2]"))).send_keys("lunch.pk")
search2=WebDriverWait( driver, 100).until(EC.element_to_be_clickable((By.XPATH, "/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/form[1]/button[1]"))).click()
click_page=WebDriverWait( driver, 50).until(EC.element_to_be_clickable((By.XPATH, "/html[1]/body[1]/div[1]/div[3]/div[1]/div[1]/div[3]/div[2]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/a[1]/span[1]"))).click()
click_photos=WebDriverWait( driver, 50).until(EC.element_to_be_clickable((By.XPATH, "/html[1]/body[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[3]/div[3]"))).click()
click_banner=WebDriverWait( driver, 50).until(EC.element_to_be_clickable((By.XPATH, "/html[1]/body[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/a[1]/img[1]"))).click()
click_Share=WebDriverWait( driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='u_1b_2']/div[2]/div/div[2]/div/span[3]/a/text()"))).click()
Here is my error:
Traceback (most recent call last):
File ".\facebook.py", line 24, in <module>
click_Share=WebDriverWait( driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='u_1b_2']/div[2]/div/div[2]/div/span[3]/a/text()"))).click()
File "C:\Users\Hamza Lachi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\support\wait.py", line 71, in until
value = method(self._driver)
File "C:\Users\Hamza Lachi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 297, in __call__
element = visibility_of_element_located(self.locator)(driver)
File "C:\Users\Hamza Lachi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 128, in __call__
return _element_if_visible(_find_element(driver, self.locator))
File "C:\Users\Hamza Lachi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 148, in _element_if_visible
AttributeError: 'NoneType' object has no attribute 'is_displayed'
Iמ
return element if element.is_displayed() == visibility else False