Enrico Bergamini
2016-04-12 12:42:51 UTC
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
<https://stackoverflow.com/questions/36532523/selenium-unable-to-click-facebooks-like-button>
)
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
difficult cause clickable elements are hidden inputs in a form. (full
details here
<https://stackoverflow.com/questions/36532523/selenium-unable-to-click-facebooks-like-button>
)
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
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/986c3e2c-536c-45b6-ae7e-198f674c92c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/986c3e2c-536c-45b6-ae7e-198f674c92c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.