ruby - expected one of [String, Regexp], got 1:Fixnum (TypeError) in page-object -
i trying find image , using if condition image exists?
performing delete operation. if not addition. getting following error when doing so..
html:
<div class="xicgridviewport"> <table id="patetrngrid-100228" class="xicgrid xicgridloaded" cellspacing="0" cellpadding="0"> <colgroup> <thead> <tbody> <tr id="id328" class=" xicgridrow0"> <td> <td> <td> <td> <td> <td> <td style="text-align: center;"> <td style="text-align: center;"> <a id="celliconlink2a" href="#" onclick="var wcall=wicketsubmitformbyid('form9', '?wicket:interface=:0:form:multiplepatternbuildergroupbox:patterngroupbox:patetrngrid:gridcheckgroup:xicgridcontainer:xicgrid:rows:3:cells:8:cell:celliconlink::iactivepagebehaviorlistener:0:-1&wicket:ignoreifnotactive=true', 'multiplepatternbuildergroupbox:patterngroupbox:patetrngrid:gridcheckgroup:xicgridcontainer:xicgrid:rows:3:cells:8:cell:celliconlink' ,null,null, function() {return wicket.$$(this)&&wicket.$$('form9')}.bind(this));;; return false;"> <img class="xicicon xiciconloaded xicicondelete" xic:size="s" xic:icon="delete" src="/uit/xicola/2.3/img/spacer.png"> <!-- here, using if condition --> </a> </td> </tr> </tbody> <tfoot> </table> </div>
code:
pattern_builder_page.rb
class builderpage include pageobject text_field(:area, name: /area/) select_list(:load_type, name: /loadtype/) checkbox(:link_power, name: /linkpower/) image(:plus, css: ".xicicon.xiciconloaded.xiciconadd") image(:delete_icon, css: ".xicicon.xiciconloaded.xicicondelete") button(:delete, text: 'delete') def create_pattern(category, place, destination) train_category_element.when_present self.train_category = category fac_place_element.when_present self.fac_place = place fac_destination_element.when_present self.fac_destination = destination wait_element.when_not_visible refresh_element.when_present refresh wait_element.when_not_visible if delete_icon_element.exists? delete yes_element.when_present.click end end end
error:
expected 1 of [string, regexp], got 1:fixnum (typeerror) ./lib/pages/pattern_builder_page.rb:22:in `create_pattern' ./features/step_definitions/bulk_steps.rb:30:in `/^i select "(.*?)", "(.*?)" , "(.*?)" facility , submit$/' features\pattern_builder.feature:11:in `when select "<category>", "<place>" , "<destination>" facility , submit'
based on exception message, coming watir-webdriver's elementlocator:
valid_whats = [string, regexp] def check_type(how, what) case how when :index unless what.kind_of?(fixnum) raise typeerror, "expected fixnum, got #{what.inspect}:#{what.class}" end else unless valid_whats.any? { |t| what.kind_of? t } raise typeerror, "expected 1 of #{valid_whats.inspect}, got #{what.inspect}:#{what.class}" end end end
this method shows locator values can numeric :index
locators.
this implies in 1 of locators, passing number locator not :index
. example have:
# invalid accessor: div(:field_name, :id => 1) # or called watir-webdriver: browser.div(:id => 1).text
as per comments, there xpath: 1
locator instead of index: 1
locator.
Comments
Post a Comment