Ruby+Appium+testunit实现app自动化demo

2022/6/25 1:21:03

本文主要是介绍Ruby+Appium+testunit实现app自动化demo,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.安装对应库

gem install test-unit

gem install appium_lib

2.编写代码

代码如下:

require 'appium_lib'
require 'test-unit'

class EditorTest < Test::Unit::TestCase
  def setup
    caps = {}
    caps['fullreset'] = false
    caps['platformName'] = 'Android'
    caps['uiautomator2ServerInstallTimeout'] = '100000'
    caps['platformVersion'] = '10'
    caps['deviceName'] = 'Galaxy A11'
    caps['automationName'] = 'UiAutomator2'
    caps['newCommandTimeout'] = '1000'
    caps['appActivity'] = 'com.atlasv.android.mvmaker.mveditor.SplashActivity'
    caps['appPackage'] = 'vidma.video.editor.videomaker'
    caps['autoGrantPermissions'] = false
    caps['noReset'] = true
    appium_driver = Appium::Driver.new({
                                         'caps' => caps,
                                         'appium_lib' => {
                                           :server_url => "http://127.0.0.1:4723/wd/hub"
                                         } }, true)
    @driver = appium_driver.start_driver
  end

  def test_editor_search
    sleep 5
    @driver.find_element(:id, "vidma.video.editor.videomaker:id/ivAdd").click
    sleep 3
    @driver.find_elements(:id, "vidma.video.editor.videomaker:id/ivIcon")[6].click
    sleep 3
    @driver.find_element(:id, "vidma.video.editor.videomaker:id/tvNext").click
    sleep 3
    @driver.find_element(:id, "vidma.video.editor.videomaker:id/ivBack").click
  end

  def teardown
    @driver.quit
  end
end


这篇关于Ruby+Appium+testunit实现app自动化demo的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程