watir

How to remove all non - ASCII characters from a string in Ruby

别说谁变了你拦得住时间么 提交于 2019-12-03 05:53:23
问题 I seems to be a very simple and much needed method. I need to remove all non ASCII characters from a string. e.g © etc. See the following example. #coding: utf-8 s = " Hello this a mixed string © that I made." puts s.encoding puts s.encode output: UTF-8 Hello this a mixed str ing ┬⌐ that I made. When I feed this to Watir, it produces following error:incompatible character encodings: UTF-8 and ASCII-8BIT So my problem is that I want to get rid of all non ASCII characters before using it. I

How to enter password in a popup using watir?

送分小仙女□ 提交于 2019-12-03 03:47:43
I'm writing some watir test cases: browser.goto "http://egauge2592.egaug.es/" browser.link(:href,"/settings.html").click browser.text_field(:index,4).set("some text") browser.button(:id,"save_button").click then a 'Authentication Required' dialogue opens, asking for username and password . No matter how I tried, I couldn't access the text fields. I tried send_keys and JavaScript. I also tried Watir.autoit but it says undefined method. I'm using watir on a Ubuntu machine with the FireFox browser. How to fill in username and password fields of that dialogue box? I was able to enter username with

watir-webdriver wait for page load

丶灬走出姿态 提交于 2019-12-02 19:15:48
Using watir-webdriver , how do i wait for a page to load after i click a link? At the moment i am doing: sleep n But this is not ideal as the page response varies so much. Is there a method to test whether the page is ready or whether there is a certain element in the page. I understand in the normal watir gem there is Watir::Waiter.wait_until or something similar, but I cannot see this in the webdriver version. marc I don't know if they're the best way, but this is how I'm handling this for waiting for updating div to clear: while browser.div(:id=>"updating_div").visible? do sleep 1 end This

RUBY/WATIR/RASTA: Pass the value from the excel/rasta to an array in Ruby?

女生的网名这么多〃 提交于 2019-12-02 14:03:47
How to pass the value separated with comma from the excel/rasta to an array in Ruby. html looks like this, .... <li><input type="checkbox" name="order:1" />Burger</li> <li><input type="checkbox" name="order:2" />Pasta</li> <li><input type="checkbox" name="order:3" />Fries</li> ... EXCEL looks like this... Orders Burger, Pasta this code doesnt work attr_accessor :orders order = [@orders] order.each do |i| ....... ........ It should look like this in ruby... attr_accessor :orders orders = [ 'burger','pasta '] *#should pass data from excel in the array "**orders**" orders.each do |i| @browser

Ruby with Watir: Handling javascript popup window

久未见 提交于 2019-12-02 09:42:35
I have a problem with watir and javascript popup window here's my test script require 'watir' browser = Watir::Browser.start "/url/" browser.link(:text, /Add New Blog/).wait_until_present browser.link(:text, /Add New Blog/).click // Here is where the javascript window popup window = browser.ie.Document.ParentWindow browser.window(:title, /Blog/) do browser.text_field(:id, /text title of Blog/).set 'Watir' browser.select_list(:id, /dropdownlist type/).select ("News") browser.button(:value, /Save/).click end The problem is after window popup shows , it's unable to locate the element of the text

Passing multiple files to input node with Watir (using Ruby)

和自甴很熟 提交于 2019-12-02 09:28:16
问题 So I have hit a bit of a snag. I am trying to automate a test case where I need to pass multiple files to an input node and I cannot figure out how to do so. I can use either Mechanize or Watir, but have found very little information on a topic that seems relatively major in automation. In the snippets below, I'm using Watir with Ruby. The main issue I'm having is that it seems when multiple files are selected, the input node is no longer visible. The input node does accept multiple files,

How to get index of parent element using Watir Webdriver?

為{幸葍}努か 提交于 2019-12-02 09:15:50
问题 I have this HTMLcode: <div class="A"> <div class="B"> Text1 </div> </div> <div class="A"> <div class="B"> Text2 </div> </div> So i need to find index of div class='A' where i find some text. I use Watir Webdriver and now i have this code: if @ff.div(:class=>'A').div(:text=>'Text1') then ind=@ff.div(:class=>'A').index end but of course this doesn't work saying 'undefined local variable or method `index''. 回答1: There's no way to get the index using the webdriver since they are relative to the

Finding a list of divs with a specific class in Watir

核能气质少年 提交于 2019-12-02 07:39:21
问题 We have n-number of divs on the page with the same class name. <div class="errors"> </div> <div class="errors"> Foo is invalid </div> What we'd like to do is to check and see if any of the divs with the "error" class on them have the message "Foo is invalid". We can do this @browser.div(:class => 'errors', :index => 2) But that doesn't cover the case where the message is in the first or n-th div. What would be great is if we can get all the matching divs back as an array, flatten it out, and

Passing multiple files to input node with Watir (using Ruby)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 06:40:58
So I have hit a bit of a snag. I am trying to automate a test case where I need to pass multiple files to an input node and I cannot figure out how to do so. I can use either Mechanize or Watir, but have found very little information on a topic that seems relatively major in automation. In the snippets below, I'm using Watir with Ruby. The main issue I'm having is that it seems when multiple files are selected, the input node is no longer visible. The input node does accept multiple files, and passing in a single path does result in a successful upload, like so. path1 = "/path/to/file.json"

How to get index of parent element using Watir Webdriver?

喜夏-厌秋 提交于 2019-12-02 06:28:08
I have this HTMLcode: <div class="A"> <div class="B"> Text1 </div> </div> <div class="A"> <div class="B"> Text2 </div> </div> So i need to find index of div class='A' where i find some text. I use Watir Webdriver and now i have this code: if @ff.div(:class=>'A').div(:text=>'Text1') then ind=@ff.div(:class=>'A').index end but of course this doesn't work saying 'undefined local variable or method `index''. There's no way to get the index using the webdriver since they are relative to the collection of matched elements. What you can try to do is collect the elemetns text as Array and then get the