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.('Alerts')
app.('Alerts').ref
app.('Alerts').name
app.('Alerts').click
app.partial_texts('Create')[1].click
app.alert_text
app.accept_alert
app.('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.('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.('Back').click
app.('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.('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.('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.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request