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

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.?

Related

Selenium with Robot

I am automating the GUI using Robot framework with selinium2Library. I am using selenium IDE and I don't find any record and play option for the Robot framework.
Is it possible for record and play back option for the test cases with Robot framework using selenium2Libbrary instead of writing test cases manually?. Appreciate some early response on this one.
Looks like you might got in confusion because of the work selenium which is different when you use it in RobotFramework.
I believe that you have to write the test cases, and you may Pycharm IDE where you get the context help for the in built as well for the user written keywords when the resources are imported.
However, I remember reading in a thread, but could not trace it. Here you can find article on how you can use Selenium IDE to record, but haven't tried myself. You may try it and see how it goes for you.
But I strongly believe that if you write the test, you can organize them into different reusable keywords than depending on the recording the stuff. Good luck.

Selenium 2.0 / webdriver

I am currently looking at choosing a automated web testing framework for use with a current web project. I am pretty sure that I am going to use selenium. I have been reading a little about selenium 2.0 or webdriver. Does webdriver have a recorder plugin like selenium 1.0 or is it just an API for web tests?
I would appreciate it if anyone could point me in the direction of some good examples of using it.
Thanks
The maintainers of Selenium, sort of answer this question here:
http://www.viddler.com/explore/saucelabs/videos/27/
Look for timestamp 00:56:00 and 00:43:00
Basically, there will probably be IDE support for Selenium 2 eventually. But it isn't there yet and it's not clear what it will look like.
You should probably be avoiding the IDE anyway. The tests that you record using the IDE tend to be fragile, unmaintainable and hard to read. Once you've learned the basics of Selenium, it's probably better to write your tests in a real programming language.
Have you seen - http://seleniumhq.org/docs/03_webdriver.html and
http://seleniumhq.org/docs/04_webdriver_advanced.html
Using Selenium IDE we can format recorded code in different languages - Selenium IDE > Option > Format
But did not see any formatter for webdriver, though bumped on to this -
https://addons.mozilla.org/en-US/firefox/addon/webdriver-backed-formatters/
Only a few minor adjustments are required to get the existing 1.0 C# scripts running under the 2.0 beta of Selenium.
Check out this blog post
Once the RTW release of Selenium is ready, I'm hoping that a better formatter is ready. Until then, I'm able to use my scripts.
You can use Selenium IDE 1.9.x (I am using 1.9.1) or 1.8.x for recording purpose. And then you can export the recording tests into your desired programming language. For example, if you want to convert your recording code (recorded by Selenium IDE) into C# , follow the steps below:
Click File menu at Selenium IDE
Mouse over "Export Test Case As" and then click "C#/NUnit/WebDriver"
Save the file at your desired location
In the same way, you can convert your code to Java, PHP, Ruby etc.
Note: Some code might not be converted exactly in some cases. In that case, it needs to modify code manually

What are the different versions of Selenium, and which one should I get?

I'm trying to get started with Selenium, but it's extremely confusing for anyone who still doesn't know the project.
If I go to the Selenium download page I get 7 download links for things with different names, and no description of what is each one. And then the Selenium 2 download link points to a page with another 8 files.
What does all of that mean? Which ones are deprecated? Which files should I get?
What are the differences between version 1 and 2? Is the version 1 deprecated, or do we still need to mix some modules from version 1 together with version 2?
And then, after searching on Google, I find Which Selenium Tool Should I Use?, but it's a very outdated page (last edited in 2007). It also talks about a limitation of the JavaScript testing interface: Same Origin Policy. Does this limitation still apply nowadays?
What are "Selenium Core", "Selenium Remote Control", "Selenium IDE"?
How about "Selenium (standalone) Server"? Is it the same thing as the Remote Control, or something different? What is the difference between Selenium Remote Control and Selenium Server?
And then I reach an official FAQ that is also confusing, and talks about a WebDriver thing that was going to be part of Selenium. Is it already inside Selenium? Is that FAQ up-to-date? How does it relate with other Selenium parts?
After all, another way to understand this question is: "I've never used Selenium before, I'm completely lost, and the documentation doesn't help." What I need is an introduction of what are all the parts of the project, which ones are old and deprecated, which ones are needed, which ones are interchangeable, which ones work with different browsers...
(maybe it would be a nice idea to have a community wiki answer that tries to be as accurate and detailed as possible)
I'm not much experienced with Selenium, but recently I have started it to automate form submissions while unit testing. For starters, try Selenium IDE. It is a Firefox addon which will help you to record actions and modify/replay them.
Actually more than that. You can perform Accessor operations, which will perfom a series of recorded/configured actions and will store the end results for us to analyze later.
And then there is Assertions, which will actually check the end state of a series of actions with some pre-configured conditions.
One thing I can say you is that Selenium is very handy and easy to learn. You can write your own test cases using plain html!
Here is a great beginner video - http://wiki.openqa.org/download/attachments/400/Selenium+IDE.swf?version=1
After seeing that, read through this tutorial - http://jroller.com/selenium/
And after that, read this reference - http://release.seleniumhq.org/selenium-core/1.0/reference.html
It explains everything you need to know. If you are first to Selenium, you will be amazZzed to see what all things selenium can do.

Selenium 1 vs 2

I am starting up a test suite for an internal JavaScript UI library for the place I work.
I have written about 10 Selenium 1 test cases or so in Python, for exploratory purposes, and so far it's gone well. I wrote the tests in Python and am using RC to run the tests in IE7,8,FF and Safari on the Mac so far so good.
I know Selenium2 is in alpha but read somewhere that it's production ready, whatever that means.
1) Since I am just starting out writing this suite, should I be using the webdriver API and Sel2, or is that not ready for prime time?
2) Can I use Sel2 with RC yet? It's unclear to me from Selenium's website if that is possible.
3) Anyone have experience with the Python driver for selenium 2? Or should I just write tests in Java?
Disclaimer: I am a Selenium Committer
I would say write your tests in Selenium 2 where possible as the bits that are complete are ready for use and work well.
There are bits that have not been fully implemented yet like how to handle alerts and a few others but the current API is stable, what it does in the background is changing but that shouldn't affect your tests unless we introduce a bug.
You can use Selenium 2 with RC.
http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.0a5.jar
I would use the Java API if possible. Since the other APIs are ports and are not as up to date.

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.