I'm new to Python and Selenium, and I just ran into a problem. I'm trying to make a script that will automatically click on the LIKE button of a Facebook page (in a pop-up).
EDIT - Localhost Webpage code:
<html>
<head>
<title>Link to Facebook Page</title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<body>
<center>
<div id="fb_like">
<a href="https://m.facebook.com/AdagioTV" target="_blank"><img src="fblogo.png"></a>
</div>
</center>
</body>
</html>
I have the following 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
import time
webpage = r"http://localhost/like/" # local web
driver = webdriver.Firefox()
driver.get(webpage)
sbox = driver.find_element_by_class_name("fb_like")
sbox.click()
print "opened fb popup"
Now, the page opens the mobile version of our facebook page (IN A POP-UP), which is something like: https://m.facebook.com/AdagioTV
I have the following code in order to wait for the page to load and click the like button:
time.sleep(5)
print "slept 5 seconds" # page loading time
WebDriverWait(driver, delay).until(EC.presence_of_all_elements_located((By.ID, 'action_bar')))
likebutt = driver.find_element_by_link_text('Like')
likebutt.click()
However, this will not FIND the elements, neither Like or action_bar, and it will ever-sleep. What am I doing wrong here? Thanks!