在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
os x自带了ruby,所以安装就省了 不过还要安装下Bundler,在我大天朝,gem install bundle有可能报找不到bundle的错误,局域网嘛,多试几次。不行就上个代理
Install Bundler: Install Gems: 这样就算准备好了 跑一下官网给的例子程序 目前appium貌似最高只支持7.1 昨天手贱升级了下xcode到6.0,找了下貌似没发现什么解决办法。 不得不又还原到低版本 ruby simple_test.rb成功启动模拟器,运行了TestApp。这样ios环境方面算是准备好了 # GETTING STARTED # ----------------- # This documentation is intended to show you how to get started with a # simple Appium & appium_lib test. This example is written without a specific # testing framework in mind; You can use appium_lib on any framework you like. # # INSTALLING RVM # -------------- # If you don't have rvm installed, run the following terminal command # # \curl -L https://get.rvm.io | bash -s stable --ruby # # INSTALLING GEMS # --------------- # Then, change to the example directory: # cd appium-location/sample-code/examples/ruby # # and install the required gems with bundler by doing: # bundle install # # RUNNING THE TESTS # ----------------- # To run the tests, make sure appium is running in another terminal # window, then from the same window you used for the above commands, type # # bundle exec ruby simple_test.rb # # It will take a while, but once it's done you should get nothing but a line # telling you "Tests Succeeded"; You'll see the iOS Simulator cranking away # doing actions while we're running. require 'rubygems' require 'appium_lib' APP_PATH = '/Users/zhangminjie/Documents/AppiumTest2/apps/TestApp/build/Release-iphonesimulator/TestApp.app' desired_caps = { caps: { platformName: 'iOS', versionNumber: '7.1', deviceName: 'iPhone Simulator', app: APP_PATH, }, appium_lib: { sauce_username: nil, # don't run on Sauce sauce_access_key: nil } } # Start the driver Appium::Driver.new(desired_caps).start_driver module Calculator module IOS # Add all the Appium library methods to Test to make # calling them look nicer. Appium.promote_singleton_appium_methods Calculator # Add two numbers values = [rand(10), rand(10)] expected_sum = values.reduce(&:+) # Find every textfield. elements = textfields elements.each_with_index do |element, index| element.type values[index] end # Click the first button button(1).click # Get the first static text field, then get its text actual_sum = first_text.text raise unless actual_sum == (expected_sum.to_s) # Alerts are visible button('show alert').click find_element :class_name, 'UIAAlert' # Elements can be found by :class_name # wait for alert to show wait { text 'this alert is so cool' } # Or by find find('Cancel').click # Waits until alert doesn't exist wait_true { !exists { tag('UIAAlert') } } # Alerts can be switched into button('show alert').click # Get a button by its text alert = driver.switch_to.alert # Get the text of the current alert, using # the Selenium::WebDriver directly alerting_text = alert.text raise Exception unless alerting_text.include? 'Cool title' alert_accept # Accept the current alert # Window Size is easy to get sizes = window_size raise Exception unless sizes.height == 568 raise Exception unless sizes.width == 320 # Quit when you're done! driver_quit puts 'Tests Succeeded!' end end
Android上面比较简单,装了Android模拟器,启动Android模拟器 随便写了几句刚看API得来的 首先启动短信应用,然后关掉短信,再安装appium提供的测试程序,点击测试程序的add contact按钮,再滑动屏幕 require 'appium_lib' # com.android.mms caps = { caps: { platformName: 'Android', appActivity: '.ui.ConversationList', appPackage: 'com.android.mms',deviceName:'Android Emulator'}, appium_lib: { sauce_username: nil, sauce_access_key: nil } } driver = Appium::Driver.new(caps).start_driver close_app install '/Users/zhangminjie/apps/ContactManager/ContactManager.apk' caps = { caps: { platformName: 'Android', appActivity: '.ContactManager', appPackage: 'com.example.android.contactmanager',deviceName:'Android Emulator'}, appium_lib: { sauce_username: nil, sauce_access_key: nil } } driver = Appium::Driver.new(caps).start_driver driver.find_element(:name, 'Add Contact').click swipe start_x: 75, start_y: 0, end_x: 75, end_y: 500, duration: 0.8
对于我这种英文渣 中文的资料很重要 http://appium.io/slate/cn/v1.2.0/?ruby#appium http://www.cnblogs.com/nbkhic/p/3804637.html |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论