wda_lib

A simple ruby lib of binding methods for WebDriverAgent

Install

gem install wda_lib

Usage example

A simple test to show all actions on WDA IntegrationApp

require 'wda_lib'

app = WDA.new

app.x

app.homescreen

app.launch_app('com.facebook.IntegrationApp')

app.status

app.session

app.button('Alerts')

app.button('Alerts').ref

app.button('Alerts').name

app.button('Alerts').click

app.partial_texts('Create')[1].click

app.alert_text

app.accept_alert

app.button('Back').click

app.partial_text('Attri').click

app.xpath_search('StaticText', 'label', 'Label')

app.xpath_search('Button', 'name', 'Second')[0].click

app.textfield('Value').click

app.textfield('Value').send_keys('test')

app.textfield('Valuetest').clear

location = app.textfield('Value2').location

app.tap_on(location[:x], location[:y])

app.keys('Type more keys')

app.button('Back').click

sleep 1

app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click

app.text('ScrollView').click

app.text('7').scroll('down')

app.text('7').scroll('down')

app.text('7').scroll('up')

app.swipe(180, 180, 330, 100)

app.swipe(180, 180, 100, 330)

app.button('Back').click

app.button('Back').click

app.x

Example of multiple devices

iphone_testing = true
simulator_testing = true

thread_iphone = Thread.new{
  start_time = Time.now
  app = WDA.new(device_url: 'http://192.168.1.56:8100/')
  app.x
  app.homescreen
  app.launch_app('com.facebook.IntegrationApp')
  app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
  app.text('ScrollView').click
  app.text('7').scroll('down')
  app.text('7').scroll('down')
  app.text('7').scroll('up')
  app.swipe(180, 180, 330, 100)
  app.swipe(180, 180, 100, 330)
  app.button('Back').click
  app.x
  end_time = Time.now  
  p "Testing time: #{end_time-start_time}"
  iphone_testing = false
}

thread_simulator = Thread.new{
  start_time = Time.now
  sim = WDA.new
  sim.x
  sim.homescreen
  sim.launch_app('com.facebook.IntegrationApp')
  sim.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
  sim.text('ScrollView').click
  sim.text('7').scroll('down')
  sim.text('7').scroll('down')
  sim.text('7').scroll('up')
  sim.swipe(180, 180, 330, 100)
  sim.swipe(180, 180, 100, 330)
  sim.button('Back').click
  sim.x
  end_time = Time.now  
  p "Testing time: #{end_time-start_time}"
  simulator_testing = false
}

while iphone_testing || simulator_testing do 
  sleep 5 
end

Options

This lib is also providing access of selenium-webdriver method find_element and find_elements. You can do:

element = app.find_element(:link_text, 'label=Attributes')

Then you can use all methods for selenium element object:

element.click
element.name
element.size
element.rect
element.location

TODO

Add more tests...

Contributing

Welcome to get your contributions, to help improving the lib.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request