Can't use selenium commands in chromewebdriver (but working with firefox)

50 views
Skip to first unread message

Martin de laat

unread,
Dec 6, 2018, 9:50:26 AM12/6/18
to Geb User Mailing List
Hi there,


None of the selenium commands work when running the integration tests with the chromedriver, but they work flawlessly with the firefox webdriver.

I tried doubleclick and draganddropby commands.

interact {
 doubleClick
(centerClickable)
}


(centerclickable is a content, selecting on ".vis-drag-center"

I also tried to call 

def driver = browser.getDriver()
Actions action = new Actions(driver)
WebElement element= driver.findElement(By.className("vis-drag-center"))
def doubleclick = action.doubleClick(element).build()
doubleclick
.perform()


Again, this works with the firefox driver, not the chrome driver.

This leads me to believe maybe some settings are wrong? Or chromedriver requires some additional options/setup I don't know about?
Here's some stuff from the GebConfig.groovy file we use when running the integration tests locally. We're using WebDriverManager

import io.github.bonigarcia.wdm.WebDriverManager
import org.openqa.selenium.Dimension
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions


def chromeWebDriverVersion = '70.0.3538.67'


def driverFirefox = {
 
WebDriverManager.firefoxdriver().setup()
 
def driver = new FirefoxDriver()
  driver
.manage().window().setSize(new Dimension(width, height))
 
return driver
}


// ChromeDriver reference: https://sites.google.com/a/chromium.org/chromedriver/
// Download and configure ChromeDriver using https://github.com/bonigarcia/webdrivermanager
def driverChrome = {
 
WebDriverManager.chromedriver().version(chromeWebDriverVersion).setup()
 
def driver = new ChromeDriver()
  driver
.manage().window().setSize(new Dimension(width, height))
 
return driver
}




environments
{
  firefox
{
    driver
= driverFirefox
 
}
  chrome
{
    driver
= driverChrome
 
}




//driver = driverFirefox
driver
= driverChrome




Does anyone have any idea?
Also tried with chrome version 2.43









Martin de laat

unread,
Jan 3, 2019, 5:37:31 AM1/3/19
to Geb User Mailing List

Alexander Kriegisch

unread,
Jan 3, 2019, 9:39:10 PM1/3/19
to geb-...@googlegroups.com

Hi Martin.

 
So you accepted your own answer on SO rather than mine because my sample test shows that what you want to do basically works, but your application works differently. Fine. So I was thinking, why don't you create an MCVE for everyone to reproduce your problem? No need to publish any closed source stuff, just condense the problem into a small sample reproducing the issue. Then maybe the community could find out why your problem occurs in the first place and whether there is anything that can be done in Chromedriver, Selenium oder Geb in order to avoid you having to use ugly workarounds in the first place? You use open source software (OSS) and asked two communities for help. So please return something to those communities by helping to improve the OSS you use.
 
Thank you
--
Alexander Kriegisch
https://scrum-master.de
 

Martin de laat schrieb am 03.01.2019 17:37:

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/52750bc7-c083-466f-9b2a-f6a58b57cfdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Martin de laat

unread,
Jan 4, 2019, 5:04:51 AM1/4/19
to Geb User Mailing List
Hi Alexander,

You're right. I was just happy to finally get it to work and frustrated 
regarding the time it took for something trivial like triggering a double 
click or simulating a drag.
  
I spent some time digging for the root cause. I also found this thread, 
probably similar 
I'm not the only one

MCVE:

package //todo add package


import geb.spock.GebReportingSpec


class visExampleTest extends GebReportingSpec {


 
def "dragging vis-js module"() {
    given
:
    go
"http://visjs.org/examples/timeline/interaction/animateWindow.html"
    waitFor
{ $(".vis-item-content").first().displayed }
   
def visModule = $(".vis-item-content").first()
   
def xCoordinate = visModule.getX()




   
when:
//    I select and then drag the module 100 pixels right
    visModule
.click()
    waitFor
{ $(".vis-drag-center").displayed }
   
def draggable = $(".vis-drag-center")


    interact
{
      clickAndHold
(draggable)
      moveByOffset
(100, 0)


     
//Uncomment next line to get it to work with chrome
     
//moveByOffset(100, 0)


      release
()
   
}


   
then:
//    the first visModule should've moved
    xCoordinate
!= visModule.getX()
 
}


 
def "double clicking test"() {
    given
:
    go
"https://unixpapa.com/js/testmouse-2.html"
    waitFor
{ $("#link").displayed }
   
def clickable = $("#link")


   
when:
    interact
{
      doubleClick
(clickable)
   
}


    println
("browser ID: " + $("body > tt").text())
    println
("action log: " + $("body > table > tbody > tr > td:nth-child(1)
> form > textarea"
).value())
    sleep
(10000)


   
then:
   
true
 
}
}



So, for me, on mac, the output for the double click test was:

chrome:
browser ID: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/
537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
action log: mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
dblclick    which=1 button=0 buttons=0

(the stated browser ID (recognized by the test website) confuses me. But 
it's equal to the browser ID when I navigate to the website via my Mac with 
chrome installed)

firefoxdriver:
browser ID: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/
20100101 Firefox/64.0
action log: mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
dblclick    which=1 button=0 buttons=0

I'm a junior developer and new to the OS community. I'm kinda unsure where 
the exact fault lies and what would be the best place to share this 

Alexander Kriegisch

unread,
Jan 12, 2019, 9:08:28 AM1/12/19
to geb-...@googlegroups.com

Hi Martin.

The MCVE is helpful. But Chromedriver is by no means the only driver having issues here. The same test also fails on PhantomJS, Edge, Opera on my Windows machine. For Edge and Opera your workaround also fixes the issue, but not for PhantomJS. Maybe drag'n'drop is not supported there at all, I have not checked the documentation, just gave it a little spin. Basically I just used your test, but created a page object instead of using your hard-coded selectors. The issue is still clearly reproduceable. I also think the Chromium issue you linked in your message is what causes the problem.

Regards

--
Alexander Kriegisch
https://scrum-master.de
//    def visModule = $(".vis-item-content").first()
//    def visModule = driver.findElement(By.id("link"))

    def clickable = $("#link")


    when:
    interact{
      doubleClick(clickable)
    }


    println("browser ID: " + $("body > tt").text())
    println("action log: " + $("body > table > tbody > tr > td:nth-child(1) > form > textarea").value())
    sleep(10000)


    then:
    true
  }
}

 
So, for me, on mac, the output for the double click test was:
 
chrome:
browser ID: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

action log: mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
dblclick    which=1 button=0 buttons=0
(the stated browser ID (recognized by the test website) confuses me. But it's equal to the browser ID when I navigate to the website via my Mac with chrome installed)
 
firefoxdriver:
 
browser ID: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0

action log: mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
mousedown   which=1 button=0 buttons=1
mouseup     which=1 button=0 buttons=0
click       which=1 button=0 buttons=0
dblclick    which=1 button=0 buttons=0
 
I'm a junior developer and new to the OS community. I'm kinda unsure where the exact fault lies and what would be the best place to share this 
 
--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.

Martin de laat

unread,
Jan 12, 2019, 12:12:35 PM1/12/19
to Geb User Mailing List
Hi Alexander

Thank you for verifying. Just my luck that both Selenium actions I tried to use within Geb have different implementations across web drivers and apparently Firefox is the only one that does work instead of chromedriver being the one that doesn't work :)

So is this something that is happening within the browser's drivers or within selenium's drivers? Where could I share my/our findings? https://github.com/SeleniumHQ/selenium/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen ?

Best
Martin
Reply all
Reply to author
Forward
0 new messages