Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Selenium, does ClickAndHold work with webdriver and chrome?

Tags:

selenium

I'm trying to make a click-and-drag event work using Selenium Webdriver (2.15). It works fine when using FF, but in Chrome it does not. In Chrome, it appears to have no effect. Here's what my code looks like:

Actions builder = new Actions(GuiOps.driver);
builder.MoveToElement(fromElem).ClickAndHold().MoveToElement(toElem).Release().Build().Perform();

Has anyone gotten ClickAndHold() to work successfully using Chrome?

like image 376
Stephen Gross Avatar asked Nov 18 '25 06:11

Stephen Gross


2 Answers

Turns out this is a known issue. There's a workaround posted at http://code.google.com/p/chromium/issues/detail?id=92312 . Basically, you add a MoveByOffset(1,1) immediately after that ClickAndHold() call and it works.

like image 59
Stephen Gross Avatar answered Nov 21 '25 10:11

Stephen Gross


First post/comment here. :) Well, it worked for me. All you need to give is a bit of a pause after the "moveByOffset(1, 1)". It seems that the script is executing faster than it should. Here's a piece of code that worked for me: "actions.clickAndHold(we).moveByOffset(1, 1).pause(1000).perform();". Hope it helps.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!