Armaxis
Armaxis

Reputation: 161

Clicking on a flash button with Selenium

I'm writing some tests with Selenium RC (on C#) for our project, which uses Ext.NET, and everything was fine, before I've faced the fact, that "Upload" button used for uploading files is made on Flash. It is inserted like this:

<embed width="63" height="30" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" allowscriptaccess="sameDomain" name="adaxuploaderaddon1317040891508" bgcolor="#FFFFFF" quality="high" src="/CuteWebUI_Uploader_Resource.axd?type=file&file=uploader10.swf&_ver=1317040891509" scale="exactfit" onerror="adaxuploaderaddon1317040891508_onerror()" style="z-index: 123454; width: 63px; height: 30px; opacity: 0.01; background-color: transparent;">

So, at first I've tried this:

selenium.Click("//embed[contains(@name, 'adaxuploaderaddon')]

Of course, it didn't worked :) Then I've tried several variations, like using mouseDown, mouseUp, using clickAt, location element with css (css=embed) - but still, no luck.

In Google people say, that it's possible to click the button with Javascript, but I haven't found any good examples.

Does anyone faced this problem before?

Thanks in advance.

Upvotes: 2

Views: 2164

Answers (3)

Ema.H
Ema.H

Reputation: 2878

you can communicate with 'IJavaScriptExecutor' & 'ExecuteScript' and pilote your flash (search about ExternalInterface for more details). For exemple i take a youtube page, and pause the video :

 IWebDriver driver = new ChromeDriver();
 driver.Navigate().GoToUrl("https://www.youtube.com/watch?v=2ac4hKSfQ9s");
 driver.Manage().Window.Maximize();

 ((IJavaScriptExecutor)driver).ExecuteScript("var movie = window.document.getElementById('movie_player');"+
                    "console.log(movie);"+
                    "movie.pauseVideo();");
 driver.Quit();

So, this is a solution but here you not click but directly calling the AS3 function on click.

Hope that help :)

Upvotes: 1

Dinesh
Dinesh

Reputation: 88

are you able to detect the upload button ? if not use the object-id or class-id in the javascript that calling the flash used for flash upload button. Hope this may work.

Upvotes: 0

Mansuro
Mansuro

Reputation: 4627

You can use flashvars to communicate with the embedded swf file.

Upvotes: 0

Related Questions