Skip to content

Instantly share code, notes, and snippets.

@bbchriscesar
Created November 21, 2018 15:17
Show Gist options
  • Save bbchriscesar/d68176851eab3bff75c8d10922ad8f67 to your computer and use it in GitHub Desktop.
Save bbchriscesar/d68176851eab3bff75c8d10922ad8f67 to your computer and use it in GitHub Desktop.
from selenium import webdriver
import time
from appium.webdriver.common.touch_action import TouchAction
class DesiredCapabilities(object):
IPHONE = {
"automationName": "XCUITest",
"platformName": "iOS",
"version": "12.1",
"platform": "MAC",
"deviceName": "iPhone X",
"bundleId": "com.apple.mobilesafari"
}
selenium_grid_url = "http://localhost:4723/wd/hub"
capabilities = DesiredCapabilities.IPHONE.copy()
driver = webdriver.Remote(desired_capabilities=capabilities, command_executor=selenium_grid_url)
time.sleep(2)
driver.get_screenshot_as_file('screenshot1.png')
elem = driver.find_element_by_xpath("//XCUIElementTypeOther[@name='URL']")
elem.send_keys('https://www.google.com')
driver.find_element_by_xpath("//XCUIElementTypeButton[@name='Go']").click()
driver.get_screenshot_as_file('screenshot2.png')
search1 = driver.find_element_by_xpath("//XCUIElementTypeOther[@name='Search']")
search1.send_keys('Android')
driver.find_element_by_xpath("//XCUIElementTypeButton[@name='Google Search']").click()
driver.get_screenshot_as_file('screenshot3.png')
actions = TouchAction(driver)
actions.tap_and_hold(20, 20)
actions.move_to(10, 10)
actions.release()
actions.perform()
#driver.back()
search2 = driver.find_element_by_xpath("//XCUIElementTypeOther[@name='Search']")
search2.send_keys('iOS')
driver.find_element_by_xpath("//XCUIElementTypeButton[@name='Google Search']").click()
driver.get_screenshot_as_file('screenshot4.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment