How to handle Flash objects using Selenium Web Driver - selenium

How to handle Flash objects to perform some actions in my application. i am unable to identify the element. can any one help me for this issue

Selenium automates Web browsers.
From http://seleniumhq.org..
Selenium automates browsers. That's it.
Flash objects are impossible to automate using Selenium as flash objects are not technically 'browser driven' like javascript is. You'll have to find other software to automate Flash.
Source - I am a contributor / maintainer of the project.

If you are using Ruby language for Selenium-Webdriver automation then you can use "Gem SIKULI" using which we can deal with all Flash elements. http://rubygems.org/gems/sikuli
But it is not that much reliable.
Gem sikuli needs Jruby i.e Java+Ruby

Not possible. All you can do is do some clicking based on the coordinates, but this is really unreliable.

It is not possible to automate flash objects with selenium as selenium is only for HTML so you can use 3rd party API Sikuli for this purpose sikuli provides image based automation in which you take image of an object and then use that image as reference to perform your operation .So in other words in sikuli object identification is done via image processing
please check following simple blog posts to learn about usage of sikuli
Automating flash calculator with sikuli integration with selenium.

Add the flashdriver jar into your project and then use the FlashWebDriver method to operate the Flash file.

Related

What could be the best approach to download the files from the web page using Selenium WebDriver with C#?

I am working on an application which has one module. The functionality of a module is to "opens the web page >> browse folders >> find links (.PDF/.XLSX/.DOC) and download the files on my local system".
I get stuck in this module. Can anybody tell me the best approach to accomplish the above task?
I am using selenium web driver with C# to develop the above application.
Downloading with Selenium tends to be a quagmire, especially when dealing with cross-browser compatibility; going with JavaRobot, Sikuli, or FireFox only solutions all have their own issues
I'd suggest looking at using Selenium to get to the page with the files to download and figuring the links that way, then using WGet or similar to actually download the files.
SQA.StackExchange has couple good items here. The two best options are the WGet method mentioned above, or write a download library in native code.

How are all the tools that I'm using related to one another?

So I've been automating tests for some time, but I honestly don't think I completely understand how the tools I am using are fundamentally related to one another. I actually feel a bit embarrassed but this was the toolbox handed down to me and I just ran with it. I've since put it to incredibly good use, which I'm very grateful for.
So I'm using the following, which if I'm not mistaken is fairly common nowadays: selenium-webdriver, rspec, capybara, chromedriver
What is the relationship between all of these that allow me to accomplish what I do on a daily basis?
RSpec is the test runner framework.
Capybara is a tool for emulating user behavior on a web page, and verifying the existence of content on those web pages, there are a number of drivers for it. It comes with rack-test and selenium-webdriver drivers.
Selenium-webdriver is used to integrate with the selenium web automation framework, it supports using firefox out of the box.
Chromedriver allows selenium-webdriver to control googles chrome browser

Selecting a file in MacOS Finder when running Selenium / Capybara test script

I'm attempting to upload a file on a page that I'm testing. The attach_file method within Capybara will not work here. The reason being that the upload feature is using a JS library named file-uploader here.
I'm actually able to invoke a mouse click in order to open a Finder window (in Mac OS) to allow me to select a file to open, however I'm not sure of how to work within this window. Essentially I'd like to select a file from my desktop and just click 'Open'.
Is there a way for me to work within this window to simply choose a file by its name and then click 'Open'?
I'm working in Firefox.
Dragging the file from my desktop into a div would also work, but I can not find a way to do that in Capybara either.
Thank you.
Selenium is a browser automation tool & as such any interaction with other components of operating systems is not possible. Once a browser opens a file open/Finder window, it's no longer the browser that you're interacting with. There are tools out there which can handle them, but i am not familiar enough to give a detailed response. Google the Robot framework, or AutoIt for starters.
Alternatively, since it's a JS library you're dealing with which handles the upload, you MAY be able to use the JavascriptExecutor to call library functions directly, which doesn't simulate the user experience, but may be enough to get past your hurdle.

Is it possible to use Selenium WebDriver to drive PhantomJS?

I’m going through the documentation for the Selenium WebDriver, and it can drive Chrome for example. I was thinking, wouldn't it be far more efficient to ‘drive’ PhantomJS?
Is there a way to use Selenium with PhantomJS?
My intended use would be web scraping: The sites I scrape are loaded with AJAX and lots of lovely JavaScript, and I’m thinking this setup could be a good replacement for the Scrapy Python framework that I’m currently working with.
PhantomJS now includes the GhostDriver project.
You are also suggested to use PhantomJS directly or with a convenience library such as CasperJS. CasperJS is specifically designed to make it easy to do sequential operations to web pages, perfect for many automation tasks.
Disclaimer: I am the author of PhantomJS.
Edit: As noted in Nick's answer, GhostDriver is now included in PhantomJS.
#Joseph, since the 1.8 release GhostDriver is included in the stable release of PhantomJS. Here is the exact release notes: http://phantomjs.org/release-1.8.html.
You can simply start PhantomJS process to listen on some port, like this:
phantomjs --webdriver=PORT
Kudos to #detro and PhantomJS team for awesome work!

Testing a file streaming with selenium?

Is it possible to test a webpage which supports an export mechanism? This export mechanism streams the data displayed in a table via xml to the user. For now it's sufficient to test if the streaming works and the user receives a file, regardless of the file content. Any ideas how I can achieve this with selenium?
I googled around for a while, and according to selenium core FAQ, u may need to use firefox template to do that.
u may take a look of this:
http://oopsnullpointer.wordpress.com/2011/01/14/selenium-handling-testing-downloads-with-a-custom-profile/
I have not yet personally tested that though.
If you're using Selenium script by itself, this would be hard, if not impossible. Luckily, you can run selenium from Java, C# and more and have it integrate with JUnit, NUnit or your favorite unit testing framework. If you use one of these languages, you could use it to cause selenium to export the file to a specific location, then use C#/Java to actually go out on the file system and verify that the file was correctly exported to the location, and do any other validation on it.
For doing this development, you can typically find all the client libraries under the bin directory of Selenium server. If you're using Selenium IDE, you can even export your test cases to C#, Java, Ruby, or whatever else, or just use it as an example to manually write your own in code.
Hope that helps!