如何通过使用Appium,Ruby在RecyclerView中单击上下文

时间:2019-03-26 11:36:37

标签: ruby selenium appium

如何通过使用Appium,Ruby在RecyclerView中单击元素。我尝试了所有方式,但无法点击

我尝试了所有可能的方法

require 'selenium-cucumber'
require 'appium_lib'
def alert1
     $driver.find_element(xpath: "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button[2]") 
end
def alert2; $driver.find_element(xpath: "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button[2]") end
def phoneNumber; $driver.find_element(id: "com.accushield.familyapp:id/phone_number") end
def sendCode; $driver.find_element(id: "com.accushield.familyapp:id/send_code") end
def confirmationCode; $driver.find_element(id: "com.accushield.familyapp:id/confirmation_code") end
def submitCode; $driver.find_element(id: "com.accushield.familyapp:id/submit_confirmation_code") end
def dashboardScreen1; $driver.find_element(xpath: "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.FrameLayout[1]/android.view.ViewGroup").click end

Then(/^do user Login with OTP$/) do
    alert1.click
    alert2.click
    phoneNumber.send_keys("8131234567")
    sendCode.click
    confirmationCode.send_keys("123456")
    submitCode.click
    sleep 40

    #residentClick.click
    #$driver.find_element(xpath: "//android.widget.ImageView[@index='1']").click   
    dashboardScreen1.click
    #if dashboardScreen.displayed?
        #    puts "User has signed in successfully"
       # else
        #  puts "User sign in got failed"
        #  end

我需要单击“回收者”视图中的任何元素。请找到元素图片

https://i.stack.imgur.com/cmJ23.png

0 个答案:

没有答案