Ruby + Appium - Locator Strategy 'name' is not supported for this session - ruby

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': Locator Strategy 'name' is not supported for this session (Selenium::WebDriver::Error::InvalidSelectorError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/default.rb:107:in `request'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:678:in `raw_execute'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:656:in `execute'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:625:in `find_element_by'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/device/device.rb:440:in `find_element'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:739:in `find_element'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:242:in `rescue in block (4 levels) in promote_appium_methods'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:233:in `block (4 levels) in promote_appium_methods'
from tindermation.rb:46:in `like_button'
from tindermation.rb:75:in `<main>'
Looking for girls to match...
Apparently name is deprecated in Appium? What is the alternative? Is there some setting in Android Developer Options that will return the xpath, id, class name, accessibility id, etc. for particular UI elements?
Alternatively, I'm using Developer Options to click a UI element at a certain coordinate. For example:
def login_button
sleep 1
driver.execute_script 'mobile: tap', :x => 539, :y => 1464, :fingers => 1, :tapCount => 1, :duration => 0.5
sleep 1
driver.execute_script 'mobile: tap', :x => 871, :y => 1130, :fingers => 1, :tapCount => 1, :duration => 0.5
sleep 1
end
But I get this exception:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': Method has not yet been implemented (Selenium::WebDriver::Error::UnknownError)
Why can't I tap the login button?

Currently you need to use either xpath or id.
Alternatively if you have name you can use xpath as
//*[#name='yourName'] .
driver.find_element(xpath: "//*[#name='yourName']").click
Hope it helps!!!

You can use "Appium Inspector", the inbuilt tool with Appium GUI app or the Android SDK tool "uiautomatorviewer" to find the different attributes of UI components of the app.

Related

ruby throws exception by ldap search by empty field

I try to get some information from the LDAP (internal AD). Everything work as it should, except when I want get the data out of an empty field.
require 'net/ldap'
...
def getDatafromAD(ad_hostname,ad_dn,ad_password,username)
ldap = Net::LDAP.new :host => ad_hostname, :port => 389, :auth => {
:method => :simple,
:username => ad_dn,
:password => ad_password }
filter = Net::LDAP::Filter.eq("cn", username)
treebase = "ou=myOU,dc=example,dc=com"
attrs = ["givenName", "mobile", "mail", "cn", "sn", "person"]
ldap.search( :base => treebase, :filter => filter, :attributes => attrs ) do |entry|
puts "UID: #{entry.dn}"
puts "#{entry.cn.first}: Surename: #{entry.sn.first} Givenname: #{entry.givenName.first} Mail: #{entry.mail.first} Mobile: #{entry.mobile.first}"
end
end
This is running fine until one field is empty (in this case mobile):
Traceback (most recent call last):
16: from query_userdata.rb:79:in `<main>'
15: from query_userdata.rb:79:in `each'
14: from query_userdata.rb:81:in `block in <main>'
13: from query_userdata.rb:58:in `getDatafromAD'
12: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap.rb:782:in `search'
11: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/instrumentation.rb:19:in `instrument'
10: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap.rb:783:in `block in search'
9: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap.rb:1311:in `use_connection'
8: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap.rb:784:in `block (2 levels) in search'
7: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/connection.rb:388:in `search'
6: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/instrumentation.rb:19:in `instrument'
5: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/connection.rb:399:in `block in search'
4: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/connection.rb:399:in `loop'
3: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/connection.rb:445:in `block (2 levels) in search'
2: from /usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap.rb:786:in `block (3 levels) in search'
1: from query_userdata.rb:62:in `block in getDatafromAD'
/usr/share/gems/gems/net-ldap-0.17.0/lib/net/ldap/entry.rb:185:in `method_missing': undefined method `mobile' for #<Net::LDAP::Entry:0x000055c0d912ac60> (NoMethodError)
Can someone please give me a hint how to solve this. My knowledge/XP can not handle this.
I tried with .empty?() to check in advance, but it looks like in the moment of accessing the empty field the exception is here.
If a field is empty I would like to put a custom string ("data not there") in the output. Probably it is just a little switch and I can not find it...
Many thanks!
I've faced the same issue 2 days ago ! I can recommend 2 things:
Access entry attributes through hash keys. Calling missing methods will rise an error, but trying to access a missing key's value will return an empty array
entry[:missing_key]
# => []
entry[:missing_key][0]
# => nil
entry.missing_key.first
# => *** NoMethodError Exception: undefined method `missing_key' for #<Net::LDAP::Entry:0x00005605a06bbf88>
Use a || operator when concatenating potential nil values with a String.
puts "SN: #{(entry[:sn][0] || 'data not there')}" +
"Mobile: #{(entry[:mobile][0] || 'data not there')}" +
"Foo: #{(entry[:foo][0] || 'data not there')}"

ArgumentError when accessing pageobject widget

class MainTabsWidget < PageObject::Elements::UnorderedList
include PageObject
include PageObject::PageFactory
link(:first_link, :text => 'First')
link(:second_link, :text => 'Second')
link(:third_link, :text => 'Third')
link(:category_link, :text => 'Category')
link(:subcat1_link, :text => 'Subcat1')
link(:subcat2_link, :text => 'Subcat2')
def goto_tab_item(tab_item)
items = tab_item.split /\//
items.each do |item|
case item
when 'First'
first_link
when 'Second'
second_link
when 'Third'
third_link
when 'Category'
category_link
when 'Subcat1'
subcat1_link
when 'Subcat2'
subcat2_link
end
end
end
end
PageObject.register_widget :main_menu, MainTabsWidget , :ul
I have a page called landing page that uses the widget in the following manner....
class LandingPage
include PageObject
include PageObject::PageFactory
main_menu(:menu_tabs, :id => 'mainMenu')
def select_menu_item(item)
menu_tabs_element.go_to_tab_item item
end
end
This actually did work at one point. If you pass 'First' for select_menu_item, it will click to the page specified by first_link. If you specify 'Category/Subcat1' it will click on the category link and then subcat1.
Howerver, something changed. We are transition from watir-webdriver gem to watir (6.10) gem, and now the code gets the argument exeption
'ArgumentError: wrong number of arguments (0 for 1..2)'
This occurs when menu_tabs_element gets referenced in any way. I've run out of ideas to remedy this.
Stack Trace:
ArgumentError: wrong number of arguments (0 for 1..2)
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/element_locators.rb:10:in `element'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/elements/element.rb:191:in `respond_to_missing?'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object.rb:53:in `respond_to_missing?'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object.rb:70:in `respond_to?'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object.rb:70:in `initialize'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/platforms/watir/page_object.rb:1047:in `new'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/platforms/watir/page_object.rb:1047:in `find_watir_element'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/platforms/watir/page_object.rb:1118:in `block in define_widget_singular_accessor'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page-object-2.2.4/lib/page-object/widgets.rb:38:in `block (3 levels) in define_accessors'
./lib/pages/menu.rb:13:in `select_menu_item'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page_navigation-0.10/lib/page_navigation.rb:134:in `block in navigate_through_pages'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page_navigation-0.10/lib/page_navigation.rb:129:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page_navigation-0.10/lib/page_navigation.rb:129:in `navigate_through_pages'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/page_navigation-0.10/lib/page_navigation.rb:67:in `navigate_to'
./spec/refactor/test_spec.rb:6:in `block (2 levels) in <top (required)>'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:350:in `instance_exec'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:350:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:509:in `block in run_owned_hooks_for'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:508:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:508:in `run_owned_hooks_for'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/hooks.rb:460:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/example_group.rb:537:in `block in run_before_context_hooks'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/memoized_helpers.rb:186:in `block in isolate_for_context_hook'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/memoized_helpers.rb:182:in `instance_exec'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/memoized_helpers.rb:182:in `isolate_for_context_hook'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/example_group.rb:536:in `run_before_context_hooks'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/example_group.rb:589:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:118:in `block (3 levels) in run_specs'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:118:in `map'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:118:in `block (2 levels) in run_specs'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1896:in `with_suite_hooks'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:113:in `block in run_specs'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/reporter.rb:79:in `report'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:112:in `run_specs'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:87:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:71:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:45:in `invoke'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rspec-core-3.7.0/exe/rspec:4:in `<top (required)>'
C:/Ruby22/bin/rspec:23:in `load'
C:/Ruby22/bin/rspec:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
1 example, 1 failure, 0 passed
Finished in 6.087 seconds
Process finished with exit code 1
It is not clear to me which change in Watir would cause this issue. It seems more likely a change in Page-Object. At any rate, here are 2 solutions. Note that this was tested with Page-Object v 2.2.4.
Using Widgets
As pointed out by Alexis in Page-Object Issue 263, including page object accessor methods in widgets is not as straight forward as one would expect. In the MainTabsWidget class, instead of include PageObject, you need to do:
extend PageObject::Accessors # to get the accessor methods
attr_reader :platform # the accessor methods don't work without a platform
With this change, your page object should work.
Using Page Section
Page-Object has a page section feature that might better suit your needs. It simplifies some of the code (ie address the above issue).
You define a class to represent your main tabs section. Note that you do not need to register the section or have the multi-line setup as with Widgets.
class MainTabs
include PageObject
include PageObject::PageFactory
link(:first_link, :text => 'First')
link(:second_link, :text => 'Second')
link(:third_link, :text => 'Third')
link(:category_link, :text => 'Category')
link(:subcat1_link, :text => 'Subcat1')
link(:subcat2_link, :text => 'Subcat2')
def select_menu_item(tab_item)
items = tab_item.split /\//
items.each do |item|
case item
when 'First'
first_link
when 'Second'
second_link
when 'Third'
third_link
when 'Category'
category_link
when 'Subcat1'
subcat1_link
when 'Subcat2'
subcat2_link
end
end
end
end
The page object can simply become:
class LandingPage
include PageObject
include PageObject::PageFactory
page_section(:menu_tabs, MainTabs, :id => 'mainMenu')
end
The clicking of the menu would change to:
page.menu_tabs.select_menu_item('First')
(or you could continue to define a #select_menu_item method in LandingPage to avoid downstream changes)

Error while upgrading from Rails 3.1 to Rails 3.2

Upgrade steps were performed as mentioned in http://guides.rubyonrails.org/3_2_release_notes.html
Right now I'm on Ruby 1.8.7 and Rails 3.1.x (using system ruby). I installed RVM with ruby 1.8.7 and added to rails 3.2 and then I get the following error:
[app]$ rails console
Faraday: you may want to install system_timer for reliable timeouts
$HOME/src/qbol/tapp/config/environment.rb:16:in `add': undefined method `>' for nil:NilClass (NoMethodError)
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb:55:in `add'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb:61:in `info'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activerecord-3.2.17/lib/active_record/railtie.rb:86
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `each'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activerecord-3.2.17/lib/active_record/railtie.rb:80
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `run_initializers'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `send'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
from $HOME/src/app/config/environment.rb:48
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in `load_dependency'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/application.rb:103:in `require_environment!'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/commands.rb:40
from script/rails:6:in `require'
from script/rails:6
This is on my development box. Any idea why this is happening?
EDIT: Below is the environment.rb. The error is happening on the last line App::Application.initialize!
# Load the rails application
require File.expand_path('../application', __FILE__)
module ActiveSupport
class BufferedLogger
def self.current_user
Thread.current[:user]
end
def self.current_user=(user)
Thread.current[:user] = user
end
def add(severity, message = nil, progname = nil, &block)
return if #level > severity
message = (message || (block && block.call) || progname).to_s
level = {
0 => "DEBUG",
1 => "INFO ",
2 => "WARN ",
3 => "ERROR",
4 => "FATAL"
}[severity] || "UNKNOWN"
user=BufferedLogger.current_user
if(!user.nil?)
idstr = "uid:#{user.id}"
if !user.current_app_user.nil?
idstr.concat(", acid: #{user.current_app_user.account_id}")
end
else
idstr=""
end
message = "[%s: %s #{idstr}] %s" %
["#{level} pid: #{$$}", Time.now.strftime("%y-%m-%d %H:%M:%S"), message]
message = "#{message}\n" unless message[-1] == ?\n
buffer << message
auto_flush
message
end
end
end
# Initialize the rails application
App::Application.initialize!
The error is happening inside ActiveSupport::BufferedLogger#add method call and you appear to be monkey-patching this class. The internals of ActiveSupport::BufferedLogger have likely changing between the versions of Rails you're using.
Try removing all of the ActiveSupport::BufferedLogger code from your environment.rb to work past this error and get your app running. Then, if you still need the monkeypatch (don't know why), you'd have to rewrite it on top of the newer version of the class.

Need to implement Watirgrid,

I want to implement watirgrid, but I'm not able to do that, every time I'm getting errors related with controller and provider starting process, Also all the example over internet, none of them are working.
Could any one please help me to implement this, a full running example with steps will be a great help.
I'm trying this code:
require 'rubygems'
require 'watirgrid'
require 'watir'
require 'watir-webdriver'
# setup a controller on port 12351 for your new grid
controller = Controller.new(:ring_server_port => 12351, :loglevel => Logger::ERROR)
controller.start
# add a provider to your grid
# :browser_type => 'webdriver' if using webdriver or
# :browser_type => 'ie' if using watir...
provider = Provider.new(:controller_uri => 'druby://127.0.0.1:11235',
:ring_server_port => 12351,
:loglevel => Logger::ERROR,
:browser_type => 'webdriver')
provider.start
# connect to the grid and take all providers from it (this time only one)
grid = Watir::Grid.new(:ring_server_port => 12351, :ring_server_host => '127.0.0.1')
grid.start(:take_all => true)
# for each provider on the grid, launch a new thread to start multiple browsers
threads = []
grid.browsers.each do |browser|
threads << Thread.new do
p browser[:hostname]
p browser[:architecture]
p browser[:browser_type]
# in this case we are starting a new IE browser
b = browser[:object].new_browser(:ie)
b.goto("http://www.google.com")
b.text_field(:name, 'q').set("watirgrid")
b.button(:name, "btnI").click
end
end
threads.each {|thread| thread.join}
And Errors I'm getting is
DRb::DRbConnError: druby://127.0.0.1:11235 - #<Errno::ECONNREFUSED: No connection could
be made because the target machine actively refused it. - connect(2)>
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:729:in `each'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:729:in `open'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1171:in `new'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1171:in `open'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watirgrid-1.1.5/lib/provider.rb:141:in `start'
from (irb):44
from C:/Ruby192/bin/irb:12:in `<main>'
irb(main):045:0>
I got the same problem, I got the provider started successfully by changing the
controller_uri
to
controller_uri => 'druby://machineIPAddress:11235'

Cannot read span elements

Hi since I did gem install watir watir-classic my scripts are not reading anymore the span elements. Can you please help me to fix this problem
here my example
Source
Rented
<SPAN class="displayData" style="padding-left:2px; width: 15;"><span name="tab4RateInfoForm.vehicleGroup"/>F</span></SPAN>
My code
carGroup=browser.span(:name => 'tab4RateInfoForm.vehicleGroup').text
Error message
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:79:in `rescue in match?': name is an unknown way of finding a <span> element (tab4RateInfoForm.vehicleGroup) (Watir::Exception::MissingWayOfFindingObjectException)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:76:in `match?'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:62:in `block in match_with_specifiers?'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:59:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:59:in `all?'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:59:in `match_with_specifiers?'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:22:in `block (2 levels) in each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:140:in `block in each_element'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:139:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:139:in `each_element'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:21:in `block in each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/locator.rb:150:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/element.rb:33:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/element.rb:63:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.3.0/lib/watir-classic/element.rb:132:in `text'
Solution 1: Use css locator
You will have to use a css-locator (or xpath):
carGroup = browser.span(:css, 'span[name="tab4RateInfoForm.vehicleGroup"]').text
Solution 2: Monkey patch
Alternatively, if you have a lot of legacy scripts that use the name attribute, you can monkey patch Watir to have the name method for all elements (or specific element if desired).
Add the following to wherever you require watir:
Watir::IE.new(true)
module Watir
class Element
def name
return self.attribute_value('name')
end
end
end
Your original method should now work.
Looks like span elements can no longer be accessed via name attribute.
Try this (use generic element instead of span):
carGroup=browser.element(:name => 'tab4RateInfoForm.vehicleGroup').text

Resources