0

What I want to acheive is :

public class UploadVideo {
FlashSelenium flashapp = new FlashSelenium(null, null);
...
...

public void upload (){

flashapp.SetVariable(driver.findElement(By.id("flashInputButton")), "C:/testvid.mp4");

  }
}

but this is giving error on .SetVariable which is

The method SetVariable(String, String) in the type FlashSelenium is not applicable for the arguments (WebElement, String)

Why I am doing this because normal .sendKeys() method is not working with this element. So I want to do it with the help of flash (flex)

Please let me know what I am doing wrong and how can I correct this?
Please look here for image and html code. I have attached image here, the green one.
https://stackoverflow.com/questions/17588703/error-in-browsing-file-via-webdriver
I have tried to make the inivible element visible using:

WebElement upload = driver.findElement(By.id("html5InputFile"));
((JavascriptExecutor) driver)
                .executeScript(
                        "arguments[0].style.visibility = 'visible';",
                        upload);
upload.sendKeys("C:\\IE10test.mp4");

on running this gives "Element not visible or may not be interacted with" execption

Community
  • 1
  • 1
paul
  • 4,333
  • 16
  • 71
  • 144

1 Answers1

0

The SetVariable command changes a variable stored by the flash on the website. It does not take a webelement. If you can find the variable that stores where flash is uploading from, then you would do something like:

flashapp.SetVariable("variableName", "C:/testvid.mp4");

After you do that, you can click on the upload button.

Nathan Merrill
  • 7,648
  • 5
  • 37
  • 56
  • as per your code where I have mentioned driver.findElement(By.id("flashInputButton")), this is the element to which I want to sendKeys ("C:/testvid.mp4") – paul Jul 25 '13 at 06:26
  • I like that page you linked to. However, on the page is there an HTML `` element anywhere nearby? How does the HTML change if you manually select a file to upload? There's got to be some element you can send keys to. If that element is hidden, try looking at this answer: http://stackoverflow.com/questions/12363038/selenium-webdriver-click-on-hidden-elements – Nathan Merrill Jul 25 '13 at 13:22
  • I am sorry but I realised it late that element is hidden, so I made it visible using javascript, clicked on it and used keyboard simulation via webdriver to give path of the video that I wanted to uplaod. But problem is still there , I can make it visible but I am failing to sendKeys... – paul Jul 25 '13 at 20:08
  • When you fail to sendKeys, does that mean that its throwing an error, or is it just not uploading? – Nathan Merrill Jul 25 '13 at 21:02
  • it threw "Element not visible " exception . I have edited(appended) the code that I tried in my post. Please see. – paul Jul 26 '13 at 05:28