[wtr-general] Watir (chrome+options) failing with new versions of libs
I installed up a new machine with ruby, watir, and selenium-webdriver and the script (that still runs on the previous version) now will not start I produced a minimal script below and the reported error (with version numbers visible in the dump) Is there a workaround to get the new machine going. I tried to uninstall the gems and install the older versions but this did not appear to work and just installed the same versions again. --- simple script require 'watir' options = Selenium::WebDriver::Chrome::Options.new options.add_argument('--disable-infobars') driver = Watir::Browser.new :chrome, options: options --- result C:>watir test.rb C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.4/lib/selenium/webdriver/chrome/options.rb:43:in `initialize': wrong number of arguments (1 for 0) (ArgumentError) from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-6.6.0/lib/watir/capabilities.rb:68:in `new' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-6.6.0/lib/watir/capabilities.rb:68:in `process_browser_options' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-6.6.0/lib/watir/capabilities.rb:28:in `process_capabilities' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-6.6.0/lib/watir/capabilities.rb:15:in `to_args' from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-6.6.0/lib/watir/browser.rb:47:in `initialize' from .../watir test.rb:5:in `new' from .../watir test.rb:5:in `' previous install on an older machine still works fine waitr 6.3 selenium-webdriver 3.4.3 -- -- 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: how to resize browser to different sizes or to maximize
This should work @browser.driver.window.maximize @browser.driver.window.resize_to(900,900) -- -- 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] Suggested code amendment for: Watir::Element#flash
I'd like to suggest a minor update to Watir::Element#flash I have added three parameters to remove the hard coded values only. I gave them defaults so if not provided the function is backwards compatible. But this allows the external caller to choose what color they want to flash the element , how many time, and how fast. # # Flashes (change background color to a new color and back a few times) element. # # @examples # browser.text_field(name: "new_user_first_name").flash # browser.text_field(name: "new_user_first_name").flash("green",3,0.05) # def flash(color="yellow",flashes=5,delay=0.1) background_color = style("backgroundColor") element_color = driver.execute_script("arguments[0].style.backgroundColor", @element) flashes.times do |n| nextcolor = (n % 2 == 0) ? color : background_color driver.execute_script("arguments[0].style.backgroundColor = '#{nextcolor}'", @element) sleep(delay) end driver.execute_script("arguments[0].style.backgroundColor = arguments[1]", @element, element_color) self end -- -- 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: angular login
The solution below assumes the input fields should eb treated as input elements and uses the sendkeys, I always add the hash brackest - I just find it easier to as other attributes later. The browser new command has a few usefull switches to maximize the browser by removing user features (since there is no user), removes the popup that tells you the browser is being automated, and also removes the horrid save password feature for the session (since automation does not need or use it). Thought you might like those since this is a login. require 'watir' browser = Watir::Browser.new :chrome, :switches => %w[--disable-infobars --disable-gpu], :prefs=> { 'credentials_enable_service'=>false } browser.goto("https://apps.vizlly.com/dms-angular/#/login;) browser.input({:id=>'email'}).send_keys('bo...@gmail.com') browser.input({:id=>'password'}).send_keys('mypassword') browser.button({:text=>'Sign In'}).click browser.close() -- -- 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] Watir - some VERY slow functions
I finally found a performance issue and it was in the watir library. If a page (and dont get me started about it) has 200 plus radio buttons and your watir script decides to print all the attributes like so radios = ie.radios() for radio in radios puts radio.name puts radio.value end Then please be ready to wait for 16 Minutes . It seems it goes slower and slower as the process runs ... asking for the name or value of the 200th will take a LOT longer than asking for the name/value of the 1st. I was somewhat confused when I called ie.radios the documentation suggests it returns an array of radios. But that would imply that asking for a property on the first item in the arrray would be exactly the same speed as asking for a property on the last (which clearly it is not). Now I started to do the same parsing of the document as done by show_all_objects but I had difficulty replicating some attributes (like a links text) and some of the element types. Could someone please look at the performance issues with these functions or suggest a function that could output all the page elements. I was using the code below and calling with say puts objectlist(ie.links) puts objectlist(ie.forms) puts objectlist(ie.text_fields) puts objectlist(ie.radios) puts objectlist(ie.checkboxes) puts objectlist(ie.select_lists) puts objectlist(ie.file_fields) puts objectlist(ie.buttons) Now normally I was only outputting one when the user called sa radio (:id,'xxx') and it failed I'd output objectlist(ie.radios) so they could see all the radios that exist. But the performance has meant I have had to comment all that out for now. def objectlist(objects) objs_info = [] index=1 objects.each {|f| obj_info = [] obj_info.push(:index=#{index}) index+=1 begin if (f.object_id!=) obj_info.push(:id=#{f.object_id}) end rescue end begin if (f.name!=) obj_info.push(:name=#{f.name}) end rescue end begin if (f.text!=) obj_info.push(:text=#{f.text}) end rescue end begin if (f.value!=) obj_info.push(:value=#{f.value}) end rescue end puts obj_info.join(, ) objs_info.push(obj_info.join(, )) } return objs_info end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How do I get the page status (200, 404, 500, etc)
Thanks for all the replys. At first I was quite excited then realized they would make additional calls - the cookies, session, conversation elements would all be a nightmare. Not to mention that the load balancer may give valid results sometimes and invalid the next (say if one server is bad). The reason I do this is becase I do not treat Watir as a tool to test with but a Frameword in which to build test tools. When someone in my tool says goto I get water to go to the page, time the response, do a screenshot, spellcheck, send the page for html validation, store a summary of the elements and html, and if requested simulate a printer view of the page, etc. All somewhat a waste of time if the page is a 500 error. And I do not know what the user is going to verify next, all they said was goto I do think I have openssl in the set of tools my workbench installs ... could this be elaborate on as a solution? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: watir.rb - matches functions
So you can build a function that takes in both an Integer, String, or Regex and then matchs it without having to build a case or switch if (parameter.matches(value)) note parameter could be any of the three types and the correct match function will apply. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Posting invalid form data with Watir
Found a solution ie.text_field(itemtype,itemname).value=text works just fine. Also use the same technique to select options (choice) in a combo where that value may not already exist s = ie.select_list(itemtype,itemname) texts = s.getAllContents if (texts==[]) fail This function requires the list to contain at least one value already end o = s.option(:text,texts[0]) o.setvalue(choice) s.select_value(choice) Next will be unselecting all the radios ..., submitting forms with fields not on the form, or without pressing any or the known submit buttons. These tests are intended to ensure the Server also validates inputs and does not leave it to the Webpage. If you dont understand why this testing is important google OWASP, it is a serios threat to many systems. And users can do this using easily downloadable tools like Firefox's tamperdata. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] How do I get the page status (200, 404, 500, etc)
I must be missing something but I spent some time yesterday trying to get the page status code. But I could not find this anywhere. I want to know if the page I requested failed in some way(404,500), was from the cache(302), or was successfully fetched(200). How do I get the page status? Or even the page header (which has this in it)? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] watir.rb - matches functions
In watir.rb there are several class additions to add a matches function that is similar in each type (see below). Wouldn't it be a little more consistent if they all returned the same data types. Regexp.matches returns MatchData or nil The others return true or false class String def matches(x) return self == x end end class Regexp def matches(x) return self.match(x) end end class Integer def matches(x) return self == x end end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Posting invalid form data with Watir
In previous versions of watir I used to send 11 characters to a field that had a maxlimit of 10. This would ensure the server also checked the parameter and did something sensible (truncate or error message). The newer version seems a bit safer and ie.text_field (:index,1).set (01234567890) just truncates the input to the maxlength. Ok I accept that and found I could use ie.text_field (:index, 1).value=01234567890 in the instances where I wanted to do the server side validation. NOW THE PROBLEM How do I do that for a combo box? I want to send a value that is not in the list of options. One way might be to add the item and then send it (sorta the same thing I guess). In any case the server should again check and handle this. And I bet the next question I ask will be around Radios and Checkboxes? Setting/sending invalid values. BACKGROUND For those unfamiliar with OWASP threats (google that) and see that this is amongst the most common vulnerabilities in security. You cannot assume the web browser will safeguard inputs. In fact till now we have manually used Firefox and Tamperdata to do this. But the task is very difficult and time consuming - So I want to automate these tests too. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Problems using :afterText to select fields
I had problems with the following html labelUsername/label input type=text name=AJ8765 / ie.text_field(:afterText,'Username').set(XXX) # fails It seems the label tags cause a problem - likewise if they are any other tags span div etc Is this expected behaviour? Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] watir .. new_process .. and IE8 (beta 2)
Someone unfortunately upgraded one of my PC's. I was pleased to find miost watir scripts still ran. One did not. It was the only one that utilized two IE windows at the same time. The code below demonstrates the issue - it should open two IE windows and print DONE. It does open the browsers but the second call does notr appear to complete. The browser shows completed but the call is still waiting. I have attached the output below. Same script runs as expected in IE6 and IE7. require 'watir' puts Open #1 ie1 = Watir::IE.new_process() puts Open #2 ie2 = Watir::IE.new_process() puts DONE --- C:\C:\IE8 test.rb Open #1 Open #2 c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/waiter.rb:55:in `wait_until': Timed out after 60.03 seconds. (Watir::Exception::TimeOutException) from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/ waiter.rb:76:in `wait_until' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/ie- process.rb:20 :in `window' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/ie.rb: 133:in `_n ew_process_init' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/ie.rb: 127:in `ne w_process' from C:/IE8 test.rb:8 C:\ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Turning Javascript on and off
Just to update here is a version of my final routine Hope it helps someone else Paul -- def JavaScript(zone,on=nil,silent=nil) # if on is nil it returns true iff javascript is enabled (not it could also be off or prompt, both false) # if true it sets it to enabled # if false it sets it to disabled # It does not set it to prompt (but could - not sure why you would) # silent - set it to anything and it does not output what it is doing case (zone) when 1: zonename = Local intranet zone when 2: zonename = Trusted sites zone when 3: zonename = Internet zone when 4: zonename = Restricted sites zone else fail Arguement error when calling function JavaScript - zone # {zone} must be 1,2,3, or 4 end if (!silent) puts Call JavaScript(#{on.inspect}) end keyname = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\\'+zone.to_s key_r = Win32::Registry::HKEY_CURRENT_USER.open(keyname) if (!key_r) fail Registry HKEY_CURRENT_USER #{keyname} not found end valuename = '1400' type,data = key_r.read(valuename) if (!data) fail Registry HKEY_CURRENT_USER #{keyname} - value #{valuename} not found end javascript_was_on = (data==0) if (on==nil) if (javascript_was_on) if (!silent) puts IE Javascript is on in #{zonename} end else if (!silent) puts IE Javascript is off in #{zonename} end end return javascript_was_on end if (on) if (!javascript_was_on) key_w = Win32::Registry::HKEY_CURRENT_USER.open (keyname,Win32::Registry::KEY_WRITE) key_w.write(valuename,Win32::Registry::REG_DWORD,0) if (!silent) puts Turning IE Javascript on in #{zonename} end else if (!silent) puts IE Javascript was on in #{zonename} end end else if (javascript_was_on) key_w = Win32::Registry::HKEY_CURRENT_USER.open (keyname,Win32::Registry::KEY_WRITE) key_w.write(valuename,Win32::Registry::REG_DWORD,3) if (!silent) puts Turning IE Javascript off in #{zonename} end else if (!silent) puts IE Javascript was off in #{zonename} end end end return javascript_was_on end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] table row_count incorrect
The following watir code is enough to demonstrate the flaw in the row_count method. The table has 2 rows - but watir return 6. The problem is tables embedded in tables and the rowcount simply counting TR tags from the outside. Therefore it counts inner table rows as well Code can then fail when cycling through the rows - the code below fails when you try to access row 3 (of the 6 rows) when in fact there are only 2 rows. ie = Watir::IE.new() ie.goto(https://www.google.com/accounts/NewAccount;) t = ie.table(:index,1) puts t t.row_values(3) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: table row_count incorrect
This is not the only routine and while digging I found comments like # This method returns the table as a 2 dimensional array. Dont expect too much if there are nested tables, colspan etc. All the routines seem to use the following process rows = table object.getElementsByTagName(TR).length Now looks more like a limitation than a bug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: table row_count incorrect
Overloading the following seems to get past the limitations. Perhaps someone with more DOM experience can comment if there are any dangers One thin I did notice is that it picks up TH data cells just like TD ones class Table def row_count assert_exists return @o.rows().length end def to_a assert_exists y = [] table_rows = @o.rows() for row in table_rows puts row.to_a.inspect x = [] for td in row.cells() x td.innerText.strip end y x end return y end end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---