Reputation: 55
I am currently using the following Python and Selenium versions:
Python34 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06)[MSC v.1600 32 bit (Intel)]
Selenium VERSION 2.53.2
I am hoping someone will know the answer to this. What i am trying to achieve is to take a Facebook page, scroll it as far as it goes, and then expand all the 'comments', 'replies' and 'See More' links that appear down the page.
So far I have only tried with the 'See More' links but I cannot get it to process clicking on the link. I think my basic knowledge tells me that it finds the xpath as i don't get an error for this but I do for the .click function which is called immediately after. I have also tried using find_element_by_link_text('See More')
however this didn't work. I also managed to locate the html structures where two examples of the See More links where located however as they weren't identical i wasn't sure how to implement these:
//div[3]/div[2]/div/span/span/a/span
//div[2]/div[2]/div/span/span/a/span
//div[@id='id_58591b7145b529535706885']/span/span/a/span
//div[@id='id_58591f8225af12f45796030']/span/span/a/span
If anyone has any suggestions or amendments or alternative options then i would be grateful to here them. Thanks in advance,
import os
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#Global Variables
target = "serena.xxxx.x"
username = "[email protected]"
password = "xxxxxxxx"
#code block to log in user
def logmein():
search_box = driver.find_element_by_name('email')
search_box.send_keys(username)
search_box = driver.find_element_by_name('pass')
search_box.send_keys(password)
search_box.submit()
driver = webdriver.Firefox()
driver.get("https://www.facebook.com//")
logmein()
elm = driver.find_element_by_tag_name('html')
elm.send_keys(Keys.END)
time.sleep(2)
elm.send_keys(Keys.END)
time.sleep(2)
elm.send_keys(Keys.END)
time.sleep(2)
elm.send_keys(Keys.END)
time.sleep(2)
elm.send_keys(Keys.HOME)
# Initiates See More Open
SeeMore = driver.find_element_by_xpath("//a[@class='see_more_link']")
print("Found See More")
SeeMore.click()
print("Expand SeeMore option")
Upvotes: 0
Views: 242
Reputation: 1
"Display settings" -> "Scale and layout":
Size should be 100% - and that must match the ZOOM of your browser - also 100%
I have had this problem on IE for about 12 hours, tried all possible variations of clicking, hovering over element - then clicking, using find_element_by_link_text
, updating everything .etc. and also tried some of the things that people suggested in stackoverflow - nothing worked.
Zooming to 100% in browser and setting display scale to 100% did the trick.
Upvotes: 0
Reputation: 172
Does this help?
import os
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
#Global Variables
target = "..."
username = "..."
password = "..."
def logmein():
search_box = driver.find_element_by_name('email')
search_box.send_keys(username)
search_box = driver.find_element_by_name('pass')
search_box.send_keys(password)
search_box.submit()
driver = webdriver.Firefox()
driver.get("https://www.facebook.com//")
logmein()
SeeMore = WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.LINK_TEXT, 'See More...')))
print("Found See More")
time.sleep(2) # apparently there is some javascript execution that requires this sleep to be here.
SeeMore.click()
print("Expand SeeMore option")
Would be great to see a screenshot of the mentioned link. This way I could go to an analog Facebook page and make sure it works.
Upvotes: 1