Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulate mouseover/mouseout events? #59

Open
tdhock opened this issue Oct 26, 2015 · 3 comments
Open

simulate mouseover/mouseout events? #59

tdhock opened this issue Oct 26, 2015 · 3 comments

Comments

@tdhock
Copy link

tdhock commented Oct 26, 2015

Any ideas how I could write a test for functionality that I have implemented in a JavaScript function that is called on mouseover/mouseout events?

I found the mouseMoveToLocation function but it does not seem to generate a call to my handler function.

I also tried using executeScript but that generated an error

> remDr$executeScript('return document.getElementById("chrM").onmouseover();')
Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: ReqHand
> 
@tdhock
Copy link
Author

tdhock commented Oct 26, 2015

here is a minimal reproducible example

library(RSelenium)
startServer()
remDr <- remoteDriver(browserName="firefox")
remDr$open()

bug.html <- file.path(tempdir(), "RSelenium-bug.html")
cat('<!DOCTYPE html>
<html>
<body>

<h1 id="head"
onmouseover="',
    "this.style.color = 'red'",
    '" onmouseout="',
    "this.style.color = 'black'",
    '">My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>', file=bug.html)

remDr$navigate(paste0("file://", bug.html))

e <- remDr$findElement("id", "head")
remDr$mouseMoveToLocation(webElement=e)

output is

> remDr$mouseMoveToLocation(webElement=e)
Error:   Summary: InvalidElementState
     Detail: An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
     class: org.openqa.selenium.InvalidElementStateException

@johndharrison
Copy link
Member

Hi Toby,

Are you running this on a MAC? This is likely an issue with native events and Selenium. Depending on the version of firefox/Selenium native events may not function. You can check what versions of selenium server have support for native events for versions of firefox by referencing the changelog. For example https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG
The MRE works for example if I run it on windows with firefox 41.0.2 and selenium server 2.48.0

@tdhock
Copy link
Author

tdhock commented Oct 27, 2015

running this on Ubuntu with

thocking@silene:~/R/animint(PredictedPeaks)$ firefox --version
Mozilla Firefox 11.0
thocking@silene:~/R/animint(PredictedPeaks*)$ phantomjs --version
1.9.8
thocking@silene:~/R/animint(PredictedPeaks*)$ 

so I guess upgrading is the solution.

but also we would like to test such "native events" in phantomjs too. Is that possible? Doesn't work with the version I have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants