I'm trying to click Facebook Like button using Webdriver. You can see an example Like button at this page.
After switching to iframe I've tried:
page.execute_script("document.querySelector('.pluginConnectButton > div:first-child button').click()")
This script works in Firebug and Chrome Developer Tools after switching to iframe.
But it doesn't work in FirefoxDriver and ChromeDriver (script passes but button isn't changed to clicked one)
How can I click this button using Webdriver?
While this worked for me it seems brittle. I had to use some javascript to get the id of the iframe since FB changes the id on each page load. Luckily they're not changing the class of the iframe.
id = page.evaluate_script("$('.fb_ltr').attr('id');")
within_frame(id) do
page.first(:css, '.pluginButton').click
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With