3

O hai SQA, first post here.

I just started using Selenium a few days ago. However, I'm a little stumped getting it to work with one of my projects.

I have an HTML file containing a collection of images. Each image has an event handler, which calls a JavaScript function when I click the image, or press Enter after selecting it with the arrow keys.

However, Selenium doesn't recognize any interaction (mouse clicks or key presses) with the images no matter what I do, although I can get it to work with other sites. The "collage" is JavaScript-generated as opposed to being coded in pure HTML, although I'm not sure if that makes a difference. Any help would be appreciated.

2

how is the event triggered? does the element have an attribute say onclick?

another way to trigger javascript is to use the following example, which is more of a workaround.

WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.