|
| 1 | +# coding=utf-8 |
| 2 | + |
| 3 | +# |
| 4 | +# This script is not a demo or example. Use it when trying out AppiumForMac features, python algorithms, and debugging. |
| 5 | +# |
| 6 | + |
| 7 | +from selenium import webdriver |
| 8 | +from selenium.webdriver import ActionChains |
| 9 | +from selenium.webdriver.common.keys import Keys |
| 10 | +from random import randint |
| 11 | +import time |
| 12 | +import utilities |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +print 'Starting the WebDriver session' |
| 17 | +desiredCapabilities = {'platform':'Mac', 'commandDelay':50, 'loopDelay':0, 'implicitTimeout':utilities.defaultImplicitTimeout_sec * 1000, 'mouseMoveSpeed':60, 'diagnosticsDirectoryLocation':'~/Desktop/', 'screenShotOnError':1} |
| 18 | +driver = webdriver.Remote( command_executor='http://localhost:4622/wd/hub', desired_capabilities=desiredCapabilities) |
| 19 | + |
| 20 | +print driver.page_source() |
| 21 | + |
| 22 | +#time.sleep(5) |
| 23 | +#driver.get("Calculator") |
| 24 | +#utilities.selectMenuItemFromMenuBar(driver, "Convert", ["Area…"], "") |
| 25 | +# utilities.selectMenuItemFromMenuBar(driver, "Speech", ["Speak Button Pressed"], " and @AXMenuItemMarkChar!=''") |
| 26 | +# utilities.selectMenuItemFromMenuBar(driver, "Speech", ["Speak Result"], " and @AXMenuItemMarkChar!=''") |
| 27 | + |
| 28 | + |
| 29 | +# |
| 30 | +# |
| 31 | +# |
| 32 | +# driver.get("TextEdit") |
| 33 | +# |
| 34 | +# #utilities.selectMenuItemFromMenuBar(driver, "Format", ["Text", "Writing Direction", " Default"], "") |
| 35 | +# |
| 36 | +# #utilities.selectMenuItemFromMenuBar(driver, "Format", ["Font", "Hide Fonts"], "") |
| 37 | +# |
| 38 | +# # Close all floating windows. |
| 39 | +# driver.implicitly_wait(0.5) |
| 40 | +# while True: |
| 41 | +# floatWindowCloseButton = utilities.findElementByXPath(driver, "/AXApplication[@AXTitle='TextEdit']/AXWindow[@AXSubrole='AXFloatingWindow']/AXButton[@AXSubrole='AXCloseButton']"); |
| 42 | +# if floatWindowCloseButton != None: |
| 43 | +# floatWindowCloseButton.click() |
| 44 | +# else: |
| 45 | +# break |
| 46 | +# |
| 47 | +# driver.implicitly_wait(30) |
| 48 | +# |
| 49 | +# # Set up a new window with Rich Text and monospaced font. |
| 50 | +# if True: |
| 51 | +# ActionChains(driver).key_down(Keys.COMMAND).send_keys("n").key_up(Keys.COMMAND).perform() |
| 52 | +# time.sleep(0.5) |
| 53 | +# |
| 54 | +# window = utilities.findElementByXPath(driver, "/AXApplication[@AXTitle='TextEdit']/AXWindow[0]") |
| 55 | +# if window == None: |
| 56 | +# print "No front window!" |
| 57 | +# quit() |
| 58 | +# driver.switch_to.window |
| 59 | +# |
| 60 | +# driver.set_window_position(50, 50, "current") |
| 61 | +# driver.set_window_size(600, 400, "current") |
| 62 | +# |
| 63 | +# utilities.selectMenuItemFromMenuBar(driver, "Format", ["Make Rich Text"], "") |
| 64 | +# utilities.selectMenuItemFromMenuBar(driver, "Format", ["Font", "Show Fonts"], "") |
| 65 | +# |
| 66 | +# window = utilities.findElementByXPath(driver, "/AXApplication[@AXTitle='TextEdit']/AXWindow[@AXTitle='Fonts']") |
| 67 | +# if window == None: |
| 68 | +# print "No fonts window!" |
| 69 | +# quit() |
| 70 | +# driver.switch_to.window |
| 71 | +# driver.set_window_position(700, 50, "current") |
| 72 | +# driver.set_window_size(600, 400, "current") |
| 73 | +# |
| 74 | +# # Bring Fonts to the front and make it the key window. We need to click in each table and type-select rows. |
| 75 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXStaticText[@AXValue='Fonts']") |
| 76 | +# ActionChains(driver).click(element).perform() |
| 77 | +# |
| 78 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXSplitGroup[0]/AXScrollArea[0]/AXTable[0]/AXRow[0]") |
| 79 | +# ActionChains(driver).click(element).send_keys("Fixed Width").perform() |
| 80 | +# |
| 81 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXSplitGroup[0]/AXScrollArea[2]/AXTable[0]/AXRow[0]") |
| 82 | +# ActionChains(driver).click(element).send_keys("Monaco").perform() |
| 83 | +# |
| 84 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXSplitGroup[0]/AXScrollArea[1]/AXTable[0]/AXRow[0]") |
| 85 | +# ActionChains(driver).click(element).send_keys("Regular").perform() |
| 86 | +# |
| 87 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXSplitGroup[0]/AXGroup[0]/AXScrollArea[0]/AXTable[0]/AXRow[0]") |
| 88 | +# ActionChains(driver).click(element).send_keys("24").perform() |
| 89 | +# |
| 90 | +# element = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[@AXTitle='Fonts']/AXButton[@AXSubrole='AXCloseButton']") |
| 91 | +# ActionChains(driver).click(element).perform() |
| 92 | +# |
| 93 | +# ActionChains(driver).key_down(Keys.COMMAND).send_keys("a").key_up(Keys.COMMAND).send_keys("to AppiumForMac Welcome!!").perform() |
| 94 | +# time.sleep(1) |
| 95 | +# ActionChains(driver).send_keys(Keys.RETURN + Keys.RETURN + "oops, sorry, hang on...").perform() |
| 96 | +# |
| 97 | +# |
| 98 | +# textView = utilities.findElementByXPath(driver, "/AXApplication/AXWindow[0]/AXScrollArea[0]/AXTextArea[@AXIdentifier='First Text View']") |
| 99 | +# if textView == None: |
| 100 | +# quit() |
| 101 | +# # Drag the word "Welcome" to the beginning of the line. |
| 102 | +# lineStartX = 3 |
| 103 | +# welcomeLineY = 20 |
| 104 | +# messageLineY = 80 |
| 105 | +# welcomeX = 300 |
| 106 | +# |
| 107 | +# ActionChains(driver).move_to_element_with_offset(textView, welcomeX, welcomeLineY).double_click().click_and_hold().move_by_offset(lineStartX - welcomeX, 0).release().perform() |
| 108 | +# |
| 109 | +# utilities.findElementByXPath(driver, "/AXApplication/AXWindow[0]/AXButton[@AXSubrole='AXCloseButton']").click() |
| 110 | +# utilities.findElementByXPath(driver, "/AXApplication/AXWindow[0]/AXSheet[0]/AXButton[@AXTitle='Don’t Save']").click() |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +#"/AXApplication[@AXTitle='TextEdit']/AXMenuBar[0]/AXMenuBarItem[@AXTitle='Format']/AXMenu[0]/AXMenuItem[@AXTitle='Text']/AXMenu[0]/AXMenuItem[@AXTitle='Writing Direction']/AXMenu[0]/AXMenuItem[@AXTitle=' Default']" |
| 116 | +#"/AXApplication/AXMenuBar[0]/AXMenuBarItem[4]/AXMenu[0]/AXMenuItem[1]/AXMenu[0]/AXMenuItem[5]/AXMenu[0]/AXMenuItem[1]" |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +#utilities.selectMenuItemFromDock(driver, "System Preferences", ["Options", "Show in Finder"], "") |
| 121 | +#time.sleep(1) |
| 122 | +#ActionChains(driver).key_down(Keys.COMMAND).send_keys("i").key_up(Keys.COMMAND).perform() |
| 123 | +#time.sleep(1) |
| 124 | +#ActionChains(driver).key_down(Keys.COMMAND).send_keys("w").key_up(Keys.COMMAND).perform() |
| 125 | +#ActionChains(driver).key_down(Keys.COMMAND).send_keys("w").key_up(Keys.COMMAND).perform() |
| 126 | + |
| 127 | +#"/AXApplication[@AXTitle='Calculator']/AXMenuBar[0]/AXMenuBarItem[@AXTitle='Apple']/AXMenu[0]/AXMenuItem[@AXTitle='Recent Items']/AXMenu[0]/AXMenuItem[@AXTitle='VMs']" |
| 128 | + |
| 129 | + |
| 130 | +##'\xe2' |
| 131 | +# |
| 132 | +##print driver.desired_capabilities |
| 133 | + |
| 134 | +#driver.get("eclipse") |
| 135 | +#utilities.selectMenuItemFromMenuBar(driver, "Eclipse", ["Quit Eclipse"], "") |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +# quit the webdriver instance |
| 140 | +print 'Quitting the WebDriver session' |
| 141 | +driver.quit() |
0 commit comments