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, [email protected] 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.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.