I see the problem here. In a regular expression the '+' character has
special meaning. It indicates in this case that the previous character
can be repeated one or more times. Thus, your regular expression would
have matched "B8110002" or even "B81100000002", but won't match a URL
with a plus sign in the middle.
Try changing your test_search to 'B8110\+002'. That should work:
irb(main):010:0> url = "blah blah B8110+002 blah blah"
=> "blah blah B8110+002 blah blah"
irb(main):011:0> test_search = 'B8110\+002'
=> "B8110\\+002"
irb(main):012:0> url =~ /#{test_search}/
=> 10
irb(main):013:0>
Also, a good way to test Watir is to run it from within IRB in an
interactive mode:
C:\Documents and Settings\davids>irb
irb(main):001:0> require 'watir'
=> true
irb(main):002:0> include Watir
=> Object
irb(main):003:0> ie = IE.new
=> #<Watir::IE:0x2eb51ac...
irb(main):004:0> ie.goto('www.google.com')
=> 1.235
irb(main):005:0> ie.show_all_objects
-----------Objects in page -------------
etc.
MR wrote:
> I believe that the link that I am trying to identify generates a shortcut
> based on nearby table data. For example, if I view the page in a browser and
> hold the mouse over the link, I do NOT see the regular expression
> ('B8110+002')that I am searching for. If, however, I view the source code, I
> see the regular expression within a url that appears as such:
>
> <a
> href="/registr/ViewSections.tap?service=direct&service=1&service=sectionsTable.actions.addLink&sp=y2%2F163%2F4512%2F5885%2F5885%2F915%2F19%2Fnull%2Fnull%2Fnull%2F0%2F0%2F0%2F0%2F0%2F3.0%2F162%2Fnull%2F915&sp=SB8110+002"
> title="TEST" id="href_section_5885_for_offering_915">[add]</a>
>
> CODE snippet:
>
> test_search = 'B8110+002'
> puts test_search
> test_var = ie.link(:url,/#{linkForClass}/).exists?
> puts test_var
>
> This outputs:
> B8110+002
> false
>
> I iterated through the tables in the page. It appears that the table that I
> am searching for a link within doesn't have an ID or name.
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.openqa.org/thread.jspa?threadID=3965&messageID=10933#10933
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general