[wtr-general] Re: getting started with Watir and Watir-RSpec

2016-10-09 Thread Jarmo Pertman
Hello,

watir-rspec isn't needed per se, which means that you can use just watir 
itself. As stated in watir-rspec readme 
, it will make 
it slightly easier to manage browser opening/closing, adds few helpful 
matchers and creates nice html reports with links to files/screenshots 
created during tests. If you do not need any of these then watir-rspec is 
not needed.

However, if you're using Rails, then I suggest using watir-rails 
 since it helps you to create running 
server etc. like you're probably used to with Capybara.

Best Regards,
Jarmo

On Friday, October 7, 2016 at 10:34:13 PM UTC+3, artie...@gmail.com wrote:
>
> Thanks again to Justin for the massive help!
> My stack is running and smoking' fast!
> This next inquiry is for everyone else!  :)
>
> I am seeking most up-to-date resources for using/programming with Watir. I 
> guess that any resource prior to some particular year (2011, 2013?) is out 
> of date and not usable? Such as this book: https://leanpub.com/watirbook
>
> Here is what I think may be up-to-date:
>
> http://www.rubydoc.info/gems/watir/frames
>  + http://www.rubydoc.info/gems/watir/Watir
>  + http://www.rubydoc.info/gems/watir/Watir/Browser
>
>
> I am running Watir by invoking rspec within a Rails environment. Capybara 
> and RSpec are old comrades. 
>
> Where is the most relevant documentation and best practices for using 
> Watir/Watir-RSpec to drive the user interface of Web site.
>
> Is the primary source for Watir documentation, here?
> https://watir.com/documentation/
>
> If so, then maybe there is a problem with the wiki. 
> All the links that point to the wiki load “stubs” as if the wiki was 
> re-initialized.   
>
>
> As this is my first experience with these tools, I am not sure if I 
> require the added abstraction of Watir-RSpec or not. 
> Is Watir-RSpec essential? Or is it primarily a wrapper for the browser 
> object to reduce the visual clutter of the Watir in an RSpec spec file? 
>
> I imagine that some use cases (test cases) may use some of watir-rspec and 
> watir, both? Such as using and manipulating the browser object directly? 
> Any examples of those?
>
> In fact, I would very much appreciate any recommendations/links to any 
> relevant code examples. Even if they are old. 
>
> Even if you know of a public gist (somewhere out there) with one single 
> test, that might be very helpful to someone just starting out, please 
> consider posting a link or sending it to me via e-mail. I would like to 
> read tests written by others — from the simple to the complex. 
>
> Many thanks!
> AZ
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: goto method not found

2016-10-09 Thread Jarmo Pertman
"type: :request" is used so that RSpec would include Watir-specific helpers 
only into specs where they are actually needed (so-called 
request/integration type specs) and not into every test (e.g. regular unit 
tests, controller tests, model tests etc.).

You can remove that additional filter, but I would recommend not to do 
that. Just make sure that somewhere in your spec/rails_helper.rb or 
spec/spec_helper.rb you have the following RSpec configuration option set:
config.infer_spec_type_from_file_location!


And then start creating your "request" type specs under spec/requests 
directory for example:
spec/requests/google_spec.rb

Also, I recommend you to use watir-rails for even easier integration.

Best Regards,
Jarmo

On Wednesday, October 5, 2016 at 12:46:10 AM UTC+3, Justin Ko wrote:
>
> The "type: :request" is added when Rails is detected, which happened 
> during your installation. As a result, each of the configurations only 
> applies to examples groups that have the same metadata of "type: :request". 
> I am not a Rails developer, so I cannot explain the rationale for adding 
> the filter. At any rate, instead of removing the filter, you could have 
> also gotten the tests to run by adding the metadata to the example group - 
> ie "RSpec.describe "Google", type: :request do"
>
> In terms of getting the second test to run, it looks there have been some 
> changes in the layout of the Google results. I had to update the test to be:
>
>   it "allows to search" do
> text_field(name: "q").set "watir"
>
> # Changed the locator, as well as added when_present to wait for the 
> layout changes
> button(name: "btnG").when_present.click
>
> results = div(id: "ires")
> expect(results).to be_present.within(2)
>
> # Changed to look at divs instead of lis
> expect(results.divs(class: "g").map(&:text)).to be_any { |text| text 
> =~ /watir/ }
>
> expect(results).to be_present.during(1)
>   end
>
> Justin
>
>
> On Tuesday, October 4, 2016 at 2:37:39 PM UTC-4, artie...@gmail.com 
>  wrote:
>>
>> Thanks very much for the dialog on this, Justin. 
>> I know your time must be valuable.  
>>
>> Well, perhaps the mystery deepens. :)
>> At least for me it does. Lot for me to learn here. 
>>
>> Indeed, this entire block (with comments) was inside my 
>> ./spec/spec_helper.rb file:
>>
>> require "watir/rspec"
>>
>> RSpec.configure do |config|
>>   config.add_formatter(:progress) if config.formatters.empty?
>>   config.add_formatter(Watir::RSpec::HtmlFormatter)
>>
>>
>>   config.before :all, type: :request do
>> @browser = Watir::Browser.new
>>   end
>>
>>
>>   config.after :all, type: :request do
>> @browser.close if @browser
>>   end
>>
>>   config.include Watir::RSpec::Helper, type: :request
>>   config.include Watir::RSpec::Matchers, type: :request
>> end
>>
>>
>>
>> My Terminal scroll-back indicates I ran the installer:
>> $ watir-rspec install
>> Rails application detected.
>> Installing watir-rspec configuration into 
>> /Users/dks/Projects/spiker/spec/spec_helper.rb.
>>
>> Can anyone elaborate on the reason why the removal of the four 
>> occurrences of "type: :request", creates conditions where the goto appears 
>> to work properly. Well, honestly I did not try with only two or three. I 
>> removed all four. 
>>
>> In fact, the sample "google url" script on the github page appears to 
>> work to completion on my system. 
>>
>> May I ask further... in the sample script, why does the second test fail? 
>> I tried to fix it by changing the search string that presumably referenced 
>> the CSS id of the "Google Search" and "Feeling Lucky" button. However, when 
>> I change it to any reasonable id I discover when using GoogleChrome 
>> Developer Inspect Tool. I get various errors, including selenium 
>> ElementNotVisibleError, and Watir UnknownMethodException. I would not think 
>> making the second test pass was this challenging. Ha! How to make it pass?
>>
>> Many thanks.
>> AZ
>>
>>
>> On Tuesday, October 4, 2016 at 8:50:02 AM UTC-7, Justin Ko wrote:
>>>
>>> When I ran the install, the following was added to the spec_helper (with 
>>> the comments removed for brevity):
>>>
>>> require "watir/rspec"
>>>
>>> RSpec.configure do |config|
>>>   config.add_formatter(:progress) if config.formatters.empty?
>>>   config.add_formatter(Watir::RSpec::HtmlFormatter)
>>>
>>>   config.before :all do
>>> @browser = Watir::Browser.new
>>>   end
>>>
>>>   config.after :all do
>>> @browser.close if @browser
>>>   end
>>>
>>>   config.include Watir::RSpec::Helper
>>>   config.include Watir::RSpec::Matchers
>>> end
>>>
>>>
>>> The "goto" method is added to examples by the "config.include 
>>> Watir::RSpec::Helper" line. Though you will likely want to include all of 
>>> these lines if you are just starting out.
>>>
>>> Justin
>>>
>>>
>>>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.go