Selenium browser detection - selenium

Good morning
I have been running a few tests over the past couple of weeks and I have come up against a bit of a wall.
I am testing in IE 7 and 8 and firefox.
Basically my problem is that IE 8 does not yet support a plug in and firefox does not support a referer in a frameset, so basically I want to do is detect which browser I am using and then if its ie 7 run the tests, else skip certain tests, is this possible?
Thanking everyone in advance for their help.
Cheers
Cameron

I might be missing something (probably!) but if all you're trying to do is target tests to IE then would conditional comments work?
<!--[if ie 7]>
The tests go here.
<![endif]-->

Just a note for anyone else who reads this: the question is around using Selenium Core and the solution is designed to edit the HTML-based test suite file. If you're using Selenium RC, you obviously know which browser you launched :)

Hmmm one solution that came up in my mind... maybe it's a little bit odd, but I think it should work: let your Web app. read the HTTP UserAgent and save it as a hidden HTML input field. Then you can access it from your Selenium tests and decide whether you want to continue running them or not.
Maybe there's a better solution, I don't know.

Related

Selenium Webdriver takes long time to run

Webdriver taking a long time to run than ide why, is there a way to execute my web driver example in already opened firefox browser, Since I was new to Webdriver I need good tutorials, Please share the examples of whatever u have...
The best way is to work on it and learn as you work. Write a simple code, understand it, add complexities and figure out how to solve.
A tutorial can only help you get started.
To that end, a good starting point can be http://seleniumhq.org/docs/03_webdriver.jsp.
Use the sample codes there to start off.
Other good resources are :
http://code.google.com/p/selenium/wiki/GettingStarted
http://code.google.com/p/selenium/wiki/NextSteps
And nope, you cannot execute your test in an already opened browser.
Hope it helps.

How do you use Selenium to test if your URL is what is expected?

I'm currently learning Selenium 1.8.0, and I'd like to test whether the current URL is what I want.
I know there's a storeLocation function, but I'm not sure what else I need to do.
thanks!
selenium.getLocation() will give you the current URL in the address bar. Since you said you are learning - It would be better you learn Selenium 2 rather than selenium 1.x versions. Reasons are mentioned here
Obvious reason to move from Selenium RC to Webdriver.?

Selenium using conditional statements

I just started looking into selenium for automated testing for the past few days and am getting pretty stuck. I've been looking for documentation on this but haven't found anything very helpful but maybe one of you have found something interesting, if so I'd love to read it.
Anyway, here's the problem: I need to open up a website. This website takes in some parameters which takes the browser to another site, however if the parameters are invalid then the next site will display a message saying "An error has occurred".
If the second site doesn't error out like this we want to store a few arbitrary values and echo them later. If the site does error out we want to mark the error and move on. Right now, if the second site is invalid selenium stops running.
The only way it seems to do this is to have an if-else statement though I haven't found any mention of one in selenium. I have read somewhere that you can create some javascript on your own and then input that into selenium. The problem there is that I don't know how to actually input the javascript into selenium.
I hope that wasn't too confusing.
Thank you,
Jesse Smothermon
My coworker found it. code below:
<tr>
<td>storeEval</td>
<td>(selenium.isElementPresent("variable_looked_at")?selenium.getText("variable_looked_at"):"N/A")</td>
<td>Address</td>
</tr>
Thanks,
Jesse Smothermon
I am fairly new to selenium too, but I think what you want to do is use the Selenium IDE and export to visual studio or something. When you use selenium with visual studio (C#) you have complete control over the flow of the test. its much more easier to program something like that. but at the same time, you need to configure it with Nunit or selenium RC.
Also out there is a selenium extension called "Flow Control". I have not used it, but I believe it will allow the Selenium IDE to do if/else/etc
As a unit test, if the second site has failed, the unit test has failed. Perhaps rather than looking for a conditional processing of your unit test, fix the problem that causes the test to fail.
That may sound a little harsh and forgive me if it does, but it sounds illogical to me that you would want to take this approach.

Choosing an automated testing tool

My project is compatible only with Internet Explorer. I want the test scripts to get generated automatically as it is done in Selenium IDE.
Can i use Selenium RC to test my application? I could not use Selenium IDE as it can be used only with Mozilla Firefox.
seleniumrc works with IE. You can specify the browser and the path to it within the config file.
It can be easily integrated into night builds via ant.
stick to writing the testcase in java.
Selenium RC and Selenium Grid are both really good at running tests against IE. You can see all the browsers that are supported by Selenium here and Selenium is Designed to write for one browser and work in the rest. THere are a few little quirks that wont work in every browser but 99% of the time it will.
Selenium RC works with IE, but is very buggy with IE 6 (to the point of being unusable). Generating the scripts is not trivial and there are many methods of doing it. We have created a Firefox extension that examines objects via introspection to make click recording easy. There are many options out there but your best bet is to write your tests with Firefox/Firebug (or Chrome). They will make object location much simpler and if you are careful the locator strings should still work in IE.
There could be two answer to you question:
Besides Selenium, though it has ample of advantages, I am reading about another tool which uses same API which Selenium use. The only changes in API I have seen so far is it reduces the complexity of functions thus making it more easier and simpler for user who is learning.
The tool is called 'Helium' and it has 50% (and more) less complex functions and code as Selenium has.
The only problem with this tool is it is paid tool for learning purpose and for implementing not-so-big scale project you can use it. But yeah after some time its gonna cost you.
I have implemented some code on Helium. Please let me know , if you face any issue initially or you are thinking to implement it.
Other being, you can use Selenium Builder(http://khyatisehgal.wordpress.com/2014/05/26/selenium-builder-exporting-and-execution/) which is an advanced form of Selenium IDE. It imports your command in different languages and does work more effectively and efficiently as Selenium IDE does(http://khyatisehgal.wordpress.com/2014/05/25/selenium-builder/)
Please let me know , if you have any doubt in any of the tool.
I know Watin is compatible with IE and Firefox. If you want to generate the test code you can use the Watin Test Recorder
This of course is implying that you are using .Net
... Or you could just use the .net bindings that comes along with the latest couple of versions, then you can just run 'em through nUnit.
For ex. Selenium IDE users Katalon Recorder might be a good match. Supports different browsers.

How can I go about automating the testing of the migration of local web apps from IE6 to IE8?

I have been researching this a wee bit and it seems to boil down to:
'Eyeball Mark 1'
The best tip seems to be the use of SuperPreview from Microsoft's Expression team.
If anyone has automated a way to go about this I would love to hear about it.
Also, I believe that SuperPreview requires a work around for a password protected app to work properly. There is a work around at MSDN Blog, but if anyone has come up with another way, could you share it with me please?
Thanks in advance!
Some products, like Telerik WebUI Test Studio, lets you build your test and play a movie with the results in different browsers (not sure about IE6 and IE8 support)
Others lets you compare bitmaps of screenshots of tests in one browser and the other. The problem is that the minimum 1-bit shift will result in an test error.