Replace all hard-coded instance of the the URLs with a variable or a constant.
Store that different URLs in a hash in a file. Something like this:
URLS = { dev: 'https://url1.com', prod: 'https://url2.com'}
Then, in whatever you're using to run the script, add an option to specify the
Just a guess but the page HTML may have multiple buttons that match value:
"OK" (and you're getting the very first one, which isn't the one that you
actually want.) It's been a while but think you could add visible: true if
that's the case, then it should find the one that you're looking for.
I may be misunderstanding, but you probably want something that'll loop until
a condition is met, then poll all of the (divs, spans whatever) checking for
one with text matching job name + status. Watir has some wait functionality and
there are gems that do this also. rspec-wait's pretty good
I wrote something with Angular in mind. Some sample tests for Google's angular
components are here:
https://github.com/jfitisoff/insite/blob/master/spec/material_angular_io_spec.rb
And Google's showcase for those components are here (the tests utilize this
site):
https://material.angular.io
I
If Titus's suggestion doesn't sort it it's worth checking to see if line
breaks are getting handled properly and that the encoding is handled properly.
Found a random link:
maybe jdenen/watir-ng
|
|
|
| ||
|
|
|
||
jdenen/watir-ng
watir-ng - Identify watir-webdriver elements with ng directives | |
|
|
×
- Forwarded Message -
From: Raymond Raymundo
To: Watir General
#!/usr/bin/env ruby# Encoding: utf-8
# Paste everything into script, including the shebang and encoding# lines
above.# Don't forget to make script executable.# Usage: ./some_script.rb
/path/to/csv
require 'csv'obj = CSV.read(ARGV[0]) # ARGV is an array that will have the cmd
line args.
i'm not sure if it slows things down a lot. think you need to do some level of
checking anyway. one way of implementing this sort of thing would be to try to
write or whatever and only do polling when the op is going to fail. i suspect
it's probably done like that.
you'd be better off using
try .present? instead
From: Raja gopalan
To: watir-general@googlegroups.com
Sent: Thursday, March 23, 2017 9:52 AM
Subject: [wtr-general] Exist method is needed while I use visible method, Can
it be avoided?
I find I couldn't use visible method without
it's a browser automation tool that requires ruby, so basically if it's html
and you can use ruby then the answer is yes
From: "achirotou...@gmail.com"
To: Watir General
Sent: Wednesday, February 15, 2017 11:00 AM
Subject:
i think watir-ng just gives you the ability to use non-standard attributes
not sure if this'll work with the new watir codebase without adjustments but
we're using something like this to access a custom "role" attribute
Watir::HTMLElement.attributes << :role
module Watir class Element
Yeah, I've seen it. It's been a while since I've used ChromeDriver on a regular
basis but my recollection was that it seemed a little fussier about that sort
of thing.
From: Brian Rieck
To: Watir General
Sent: Wednesday, February
Watir models everything in the DOM. So think something like this should work
b.uls.each do |ul| ul.lis.each { |li| p li.text }end
From: "artie.z...@gmail.com"
To: Watir General
Sent: Tuesday, January 3, 2017 2:59 PM
Subject:
May be semantics, but you mentioned clicking on a link to call a button, which
could be a problem if the element truly is a link. If it's a link then you
should try to access it that way:
book_rows.a(value: /view/i).click.
There might be more than one table with that id:
@browser.tables(id:
I can't remember for sure if this is the same thing but you may want to try
this, grabbed it from our framework:
# Absolutely, positively have to have this to create browser instances via
webdriver.# Something in the Ruby stack is modifying how Kernel#exec works.
This setting# allows
It's most likely exactly what Titus suggested. One other thing you can do, in
addition to providing the HTML he asked for, is to see how many elements there
are that match. Stuff like this:
b.checkboxes(:id => 'sv').length # More than 1? If so, the one you want may be
one of the others
probably nicer ways are doing it but think this'll work
index = nilb.divs(:class, 'grid').each_with_index do |div, idx| index = idx if
div.text =~ /text6/ break if indexend
From: Soori
To: Watir General
Sent: Monday, July 18, 2016
Hard to say. If you're kicking off things with a Ruby script and that script's
above the stuff that you want to load, you may want to start off with putting
it there
From: Ajay Reddy
To: Watir General
Cc:
Ruby has a $LOAD_PATH constant that tells it where to look for things. I
usually do something like this to add something for the 'root' directory where
I have some files that I need to access:
root = File.expand_path(File.dirname(__FILE__))$LOAD_PATH.unshift(root)
And then you should be able to
may need to click on the input inside td
From: sivam
To: Watir General
Sent: Wednesday, June 8, 2016 8:46 AM
Subject: [wtr-general] Passing value to is not working
Hi all,
I am using watir 1.6.5 to interact with pages. I got
File fields have security restrictions, not sure if that'll work. Created an
HTML page with a file field to poke around, didn't have much luck. Did see
something about some workaround using send_keys and ChromeDriver but that
didn't seem to work when I tried it (maybe I missed something)
Maybe something like this. First thing to try, anyway. Method may take multiple
file args, can't remember offhand
# http://www.rubydoc.info/gems/watir-webdriver/Watir/FileField
× ['path/one.txt', 'path/two.txt'].each do |path| b.file_field(:id,
'some_id').when_present.set(path)end
Hi Jesse,
What have you tried, what does the HTML look like and what kind of errors are
you getting? It could be many things and that info might narrow down the
possibilities a bit.
John
From: "jherzen...@shastaqa.com"
To: Watir General
Yeah, that's annoying. Think I filed a Webdriver bug a one point (I wasn't the
only one) but not sure if they ever did anything with it.
If you don't have to use Chrome, It might be worth trying Firefox. Driver
install is not required for that and it's a little less fussy, although think I
Haven't used watir classic in a long time but think .hover should work.
You can always bump up the when_present time, it takes an integer argument. the
default if you don't specify a time is 30 seconds, which is a really long time,
so itmight not be as simple as that.
One thing that really
Not sure if this fits your problem, but one approach would be to look at the
output of b.div(:id, 'contents').text. It may be possible to use regexp
matching to get the text leading up to the div and then the text after, without
having to worry specifically about what element outside the table
Use a regular expression. Assuming that the URL is
http://www.mysite.com/client/abcde012345:
browser.url.match(%r{/client/(.*)})[1]
= abcde012345
From: Lorraine Botros lorraine.bot...@gmail.com
To: watir-general@googlegroups.com
Sent: Tuesday, June 16, 2015 4:24 PM
Subject:
Oh, wait! Cancel is a link
From: 'John Fitisoff' via Watir General watir-general@googlegroups.com
To: watir-general@googlegroups.com watir-general@googlegroups.com
Sent: Tuesday, May 26, 2015 7:31 AM
Subject: Re: [wtr-general] unable to click link
I think cancel needs to be in quotes
Maybe something like this would work in determining the checkbox state
b.span(:text, 'Dependent to an existing member?').parent.html =~
/custom-checkbox checked/
From: jackstaposit...@gmail.com jackstaposit...@gmail.com
To: watir-general@googlegroups.com
Sent: Tuesday, January 27, 2015
Hi all,
My company (Recurly) is looking for a QA engineer with Ruby experience to join
and help with manual testing and support an existing automation effort. We're
using Watir and RSpec. The position will involve a lot of scripting and we'll
be looking for someone with good Ruby programming
It's just saying that RSpec doesn't have a goto method. Try calling that on
@browser
From: trekr5 cebi...@gmail.com
To: watir-general@googlegroups.com
Sent: Monday, January 12, 2015 4:52 AM
Subject: [wtr-general] Undefined method 'goto' for RSpec::Core::ExampleGroup
using Watir-Rspec
Another way of checking for text (when you don't care about which particular
element is displaying it) is:
@browser.text =~ /Welcome/
From: Super Kevy kpe...@scholarshipamerica.org
To: watir-general@googlegroups.com
Sent: Friday, January 2, 2015 6:38 AM
Subject: [wtr-general] Re:
Think you need this
if @browser.text.include?(Signed in!) == true
# Something...elseend
Think there's more than one spreadsheet library but you should be able to query
the spreadsheet object for the number of of rows that it has (take a look at
the rdocs for it.) Then you could do something
Something like this should work, although it'd be better to restrict the # of
links to be checked rather than iterating through all of them
link = b.links.find {|link| link.href =~ /Page\$\d+/}link.href.match(
/Page\$\(d+)/)[1] # assumes link is actually found
From: Joe Fleck
+1 for treating it as an application bug rather then a problem with Watir. It's
likely the reason that browser.alert.exist? isn't working is that the browser
isn't responsive. The developers should look at fixing whatever's causing that
popup to show up. You might have some luck using a
35 matches
Mail list logo