【问题标题】:how to scroll a listview in android using appium?如何使用appium在android中滚动列表视图?
【发布时间】:2015-03-06 08:31:36
【问题描述】:

我用下面的语句来滚动。

  @driver.scroll_to_exact('Text').click

我收到以下错误

Selenium::WebDriver::Error::WebDriverError:unexpected response, code=404, content-type="text/plain"That URL did not map to a valid JSONWP resource

我尝试使用以下语句

     b=find_element(:id,'com.dddd.main:id/calenderListView')
     @driver.execute_script 'mobile: scrollTo', :element => b.ref`

我能够滚动到列表视图的末尾。但是滚动到列表视图的末尾后出现以下错误

  Failure/Error: @driver.execute_script 'mobile: scrollTo', :element => b.ref
 Selenium::WebDriver::Error::UnknownError:
   Could not scroll element into view: null
 # ./test.rb:68:in `block (2 levels) in <top (required)>'

【问题讨论】:

    标签: android ruby selenium appium


    【解决方案1】:

    希望这会有所帮助:

    步骤:

    Given(/^I scroll down/) do
    element = find_element :xpath, "//YOUR_ELEMENT_HERE']"
    execute_script 'mobile: scrollTo', :element => element.ref
    end
    

    特点:

    Given I scroll down
    

    你不必使用 xpath 来定位元素,如果你有 id 或 name 它会是更好的选择

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-04
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多