1

I'm trying to perform an action on a button it's never done.

final Actions action = new Actions(mDriver);
    final WebElement myCart = mDriver.findElement(By.cssSelector("path to my span"]"));
    final WebElement myButton = mDriver.findElement(By.cssSelector("path to my button"));
    action.moveToElement(myCart).build().perform();
    action.moveToElement(myButton).click().build().perform();

This code works perfectly with firefox but not with phantom JS

I found some issue here How to handle Mouseover in Selenium 2 API or How to perform mouseover function in Selenium WebDriver using Java? but nothing work with phantom.

Is there any known workaround for this ?

Thanks!

Community
  • 1
  • 1
Yodaaaa
  • 11
  • 4

1 Answers1

0

I had similar issues when I used GhostDriver and PhantomJS around a year ago (FYI article). Actually I had problems with IE_Driver and Chrome_Driver too, mostly related with visibility of elements outside the screen_frame (page must be scrolled down).

One of most serious issues was the upload_window and handle it through already-mentioned. I wasn't able to achieve it doh. But my workaround was to switch/cast the driver on these problematic places and after they complete/handle the operation - switch it back to GhostDriver. Even by doing so, the execution speed was impressive.

Hope this helps - even late given.

Update:

find IWebElement to process
set WebDriver from GhostDriver to FirefoxDriver
process the IWebElement item with current WebDriver as FirefoxDriver
verify expected result from processing the IWebElement item
set back WebDriver from FirefoxDriver to GhostDriver 
continue workflow

As far as I remember my Test framework implementation - a BaseTest class takes care of initialization of used WebDriver and ISelenium objects. So for your more specific case, you can try this:

// Create a new instance of the Ghost driver
// Notice that the remainder of the code relies on the interface, 
// not the implementation.
WebDriver driver = new GhostDriver();
//do stuff until new driver is needed
driver = new FirefoxDriver();
//do stuff with new driver
//'cast' back after required operations have been completed and verified
driver = new GhostDriver();
ekostadinov
  • 6,880
  • 3
  • 29
  • 47
  • Can you elaborate more on what you mean by *switch/cast the driver*? Maybe provide code examples. – Artjom B. Aug 21 '14 at 11:06
  • Sadly I left this code implementation with my previous Project. But if your Test framework is build with proper class hierarchy and abstarction level, the Pseudocode in my Updated answer will have to do the job just fine. – ekostadinov Aug 21 '14 at 11:37