So I'm trying to click on multiple like buttons on facebook, which is difficult cause clickable elements are hidden inputs in a form. (full details
here)
I load all the page with the multiple elements then I have 2 paths to find and click like buttons:
buttons = driver.find_elements_by_tag_name("input")
for element in buttons:
ActionChains(driver).click(element).perform()
This returns: selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: Offset within element cannot be scrolled into view: (0, 0): [object HTMLInputElement].
Probably because the element is invisible
Or I try to inject JS:
driver.execute_script("document.getElementsByClassName('commentable_item').click();");
But it returns that the function document.getElementsByClassName(...).click() is undefined.
Why? Should I use any import to make execute_script work?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import TimeoutException
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
from selenium.webdriver.common.action_chains import ActionChains