If possible does anyone have a template for setting up selenium tests using a pageObject design pattern.
What i would like to do is create a parent class which opens the browser. I can then pass that browser variable to another subclasses for pages such as LoginPage etc etc.
If anyone could be further information on this that would be great.
My main problem is getting the subclasses to inherit the browser variable.
I would really appreciate some help with this, any answer welcome to help point me in the right direction.
Cheers,
Jon
There is a page objects Gem. it works with both watir-webdriver and selenium-webdriver.
We had a 4 hour class on using that gem, watir-webdriver and cucumber at the recent test automation bazaar conference. you can find it here
Give it a shot, you can use it with either.. (and you may find you prefer the watir api to what selenium uses (I know I do) and if you like selenium, well that's an option too since the gem supports both
Related
We are working right now with Ruby, Cucumber and Selenium to perform our integration tests.
Right now we want to improve the quality of our tests and therefore we want to use Capybara.
Now since all our methods need to be rewritten for that, we thought maybe someone has already done that and wrote a wrapper for the selenium webdriver, where Capybara does the job.
For example:
The wrapper should replace the following:
driver.navigate_to "/home"
to something like
visit "/home"
The point is, we donĀ“t want to rewrite all our code, since the functionality out of my view is quite of the same and it should not be that difficult to write a wrapper for driver, which does this automatically. Means: the navigate_to method just calls a visit method, and I am happy.
Do I have to write this on my own, or was this already done?
Thanks alot!
No, there is no existing wrapper for that.
You seem to be missing the fact that Capybara is itself a wrapper around selenium-webdriver, so you are asking for a selenium compatible wrapper around a wrapper around selenium. This coupled with the fact that if all you do is emulate your existing selenium commands with Capybara commands you won't be gaining anything from Capybara, so it's pointless. It sounds like your team would be better off leaving the existing tests as they are, writing all new tests using Capybara, and as existing tests need change/maintenance rewriting them to use Capybara with it's built-in waiting/retrying and friendlier API.
I have come across two projects one is with WATIR cucumber feature files and step definitions and another one is Rspec, capybara`` withoutstep definitionsandfeature files`.
In WATIR project page_object was used and in capybara site_prism gem was used.
What is the difference between two?
Can't we use page_object in capybara would that be incorrect approach? Why?
The main difference between the two is supported underlying drivers, which is the part that actually interacts with the browser.
SitePrism supports Capybara.
Page-Object supports Watir-Webdriver and Selenium-Webdriver.
As each gem makes assumptions about the API of the driver, you cannot use unsupported drivers - ie you cannot use the Page-Object gem with Capybara.
Aside from that, it is mainly API preferences. Both gems are for creating page object models. However, the syntax for defining the page object and the methods the page object has will differ based on the preferences of each gem's author.
Does an (experimental) class browser exist for Ruby?
I am talking about a class browser/editor combination similar to that of most Smalltalk implementations (i.e. focused on [runtime] classes/objects instead of .rb files)
P.S.: it looks like pry is already able to do a lot of the things that would be needed by a smalltalk style class browser? https://speakerdeck.com/u/rahult/p/pry-an-irb-alternative-on-steroids
P.S.2: Looks like the Seaside Smalltalk framework has a web browser based class browser
P.S.3: MagLev/Webtools is the closest I have found yet:
P.S.4: Apparently http://tibleiz.net/code-browser/index.html has Ruby support and is able to present a Smalltalk like class browser:
Check out the maglev/webtools project on github, as well as the rubymirrors gem. It already provides a class browser and workspace for multiple Ruby implementations, and a graphical debugger works on MagLev as well (not so much on MRI).
If you want to build one, the easiest would be to use MOOSE and build the browser with Glamour, on top of a Ruby parser written in PetitParser. Then you could use Pharo as your Ruby IDE.
You can have a look at the Maglev Database Explorer [1, 2] as well.
[1] Video: http://www.youtube.com/watch?v=27mS1BNP7wQ
[2] Gem: https://github.com/matthias-springer/maglev-database-explorer-gem
There is. It is called Reflexive. https://github.com/dolzenko/reflexive
(I've never taken the time to try it though, so I am curious about other experiences with it.)
I have no experience with it (and it is old), but may be rbbr still works.
We are currently running rspec tests that check for specific libraries/models to be loaded. Specifically, we want to test that when creating an object, we get the correct Watir object back: Watir::Browser for FF and Chrome, and Watir::Safari for Safari.
We already tried doing this: Unload a ruby class but it just deletes the constant, which isn't what we want.
Normally, this wouldn't be a problem but due to compatibility problems with safariwatir and watir-webdriver, this is not the case. It errors out with:
superclass mismatch for class UnknownObjectException
And to 'fix' this, we basically have to choose which webdriver to load(hence the original logic - which we plan to test)
Is there a way to solve this? Our tests pass, not just when ran as a whole. So we basically have to skip a step just to circumvent the require problem.
New Anser: NEWS FLASH webdriver now supports Safari! ditch safariwatir and do it all with webdriver. I just found this out today at the Test Automation Bazaar, so don't have much in the way of details.. I'd expect to see some blog postings about this from the Watir community in the next week or so once people recover from the conference.
UPDATE: Details now up on the watir-webdriver blog regarding how to make things work with Safari
Classes in Ruby are objects, but the idea of classes as a 'one per execution/objectspace" only exists because Ruby class objects are assigned as constants.
Since your classes are namespaced with theater module, you can check the type of an object dynamically. If that isn't enough, you can duck-type. Since you mentioned compatibility issues, there are methods that exist for one that do not for another (which you can test for) or there are methods that return different values for each (which you can test for.)
I've handled something similar to this by using conditional logic when I require the 'watir' gem, so that only one version ends up being required based on what the environment is configured for. I can provide more details later, perhaps after the watir test automation bazaar is over and I have a little time to think and dig out some code samples for you.
I'm new in ruby and programming stuff in general. I have one, maybe silly question
is possible to use all the methods from rwebspec with watir-webdriver. And if it is possible, please show me.
Thanks
RWebSpec is a wrapper for all the Watir/Selenium-WebDriver methods. So by using it you are essentially using these underlying tools. There's no reason you need to explicitly need to use Watir-WebDriver.