如何使用Ruby/Appium和新的UiSelector()定义动态选择器

niknxzdl  于 2023-08-04  发布在  Ruby
关注(0)|答案(1)|浏览(105)

1.我有一个小 cucumber 步骤And I switch to "About" tab
1.步骤已创建

And (/^I switch to "([^"]*)" tab$/) do |tabName|
      @screens.main.switch_to_tab(tabName)
    end

字符串
1.方法来单击该选择器

class Main
  
  def tab_button
    @tab_button = Elements.new(:uiautomator,`new UiSelector().resourceId(tab-button-#{@tab})`)
  end

  def switch_to_tab(tabName) 
    @tab = tabName.downcase  
    tab_button 
    @tab_button.click
  end

end
And console throws error
 Could not parse selector expression `new UiSelector().resourceId(tab-button-about)`: `UiSelector` doesn't have suitable method `resourceId` with arguments ¡tab-button-about¿: Could not parse selector expression `new UiSelector().resourceId(tab-button-about)`: tab-button-about is not a string; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors£invalid-selector-exception (Selenium::WebDriver::Error::InvalidSelectorError)

的数据
怎么解决?

ifsvaxew

ifsvaxew1#

已解决使用双引号

@tab_button = Elements.new(:uiautomator, "new UiSelector().resourceId(\"tab-button-#{@tab}\")")

字符串

相关问题