Skip to content

Instantly share code, notes, and snippets.

@wgkoro
Created March 10, 2013 13:46
Show Gist options
  • Save wgkoro/5128632 to your computer and use it in GitHub Desktop.
Save wgkoro/5128632 to your computer and use it in GitHub Desktop.
Android + Selenium2 Example
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import time
import os
from selenium import webdriver
class AndroidTest:
def __init__(self):
self._browser = webdriver.Remote(command_executor='http://localhost:8080/wd/hub', desired_capabilities=webdriver.DesiredCapabilities.ANDROID)
self._current = os.path.realpath(os.path.dirname(__file__))
def main(self):
self._browser.get('http://google.co.jp/')
time.sleep(0.5)
self._browser.find_element_by_xpath('//*[@id="lst-ib"]').send_keys('Azrael')
self._browser.find_element_by_xpath('//*[@id="tsbb"]').click()
time.sleep(1)
self._browser.get_screenshot_as_file(os.path.join(self._current, 'test.png'))
self._browser.execute_script('alert(document.title);')
self._browser.quit()
if __name__ == '__main__':
ad = AndroidTest()
ad.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment