How to use open_application method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

asapp.py

Source:asapp.py Github

copy

Full Screen

...45url = 'http://127.0.0.1:4723'46remote = 'http://10.128.197.131:4723'47class asapp((unittest.TestCase)):48 def __init__(self):49 self.driver = self.open_application()50 @keyword("Open UCC in remote machine")51 def remote(self):52 driver = webdriver.Remote(str(remote), desired_capabilities={53 "app": r"C:\\Program Files (x86)\\Avaya Aura AS 5300 UC Client\\bin\\SMC.exe"})54 return driver55 @keyword("Open UCC")56 def open_application(self):57 driver = webdriver.Remote(str(url), desired_capabilities={58 "app": r"C:\\Program Files (x86)\\Avaya Aura AS 5300 UC Client\\bin\\SMC.exe"})59 return driver60 @keyword("Setup username and password")61 def setup_username_and_network(self, username, network):62 try:63 self.open_application().find_element_by_accessibility_id('5342').click()64 except NoSuchElementException:65 pass66 self.open_application().find_element(By.NAME, 'Tools').click()67 self.open_application().find_element(By.NAME, 'Preferences...').click()68 windows = self.open_application().window_handles[1]69 driver_preferences = webdriver.Remote(str(url),70 desired_capabilities={"appTopLevelWindow": windows})71 self.open_application().switch_to.window(windows)72 driver_preferences.find_element(By.NAME, 'User').click()73 driver_preferences.find_element_by_accessibility_id('5444').clear()74 driver_preferences.find_element_by_accessibility_id('5444').send_keys(username)75 driver_preferences.find_element(By.NAME, 'Network').click()76 driver_preferences.find_element_by_accessibility_id('5484').click()77 driver_preferences.find_element(By.NAME, network).click()78 driver_preferences.find_element_by_accessibility_id('5440').click()79 try:80 driver_preferences.find_element_by_accessibility_id('6').click()81 except NoSuchElementException:82 logger.info('User not change')83 logger.info('Change to username:' + username + ' and network:' + network)84 @keyword("Setup username and password in remote machine")85 def setup_username_and_network_remote(self, username, network):86 try:87 self.remote().find_element_by_accessibility_id('5342').click()88 except NoSuchElementException:89 pass90 self.remote().find_element(By.NAME, 'Tools').click()91 self.remote().find_element(By.NAME, 'Preferences...').click()92 windows = self.remote().window_handles[1]93 driver_preferences = webdriver.Remote(str(remote),94 desired_capabilities={"appTopLevelWindow": windows})95 self.remote().switch_to.window(windows)96 driver_preferences.find_element(By.NAME, 'User').click()97 driver_preferences.find_element_by_accessibility_id('5444').clear()98 driver_preferences.find_element_by_accessibility_id('5444').send_keys(username)99 driver_preferences.find_element(By.NAME, 'Network').click()100 driver_preferences.find_element_by_accessibility_id('5484').click()101 driver_preferences.find_element(By.NAME, network).click()102 driver_preferences.find_element_by_accessibility_id('5440').click()103 try:104 driver_preferences.find_element_by_accessibility_id('6').click()105 except NoSuchElementException:106 logger.info('User not change')107 logger.info('Change to username:' + username + ' and network:' + network)108 @keyword("Quit UCC")109 def quit_application(self):110 self.open_application().find_element(By.NAME, 'Close').click()111 self.open_application().find_element(By.NAME, 'OK').click()112 def quit_application_remote(self):113 self.remote().find_element(By.NAME, 'Close').click()114 self.remote().find_element(By.NAME, 'OK').click()115 @keyword("Send IM")116 def send_im(self, user_received_im, subject, content):117 self.open_application().find_element_by_accessibility_id('5353').click()118 windows = self.open_application().window_handles[1]119 driver_im = webdriver.Remote(str(url),120 desired_capabilities={"appTopLevelWindow": windows})121 self.open_application().switch_to.window(windows)122 driver_im.find_element_by_accessibility_id('5821').send_keys(user_received_im)123 driver_im.find_element_by_accessibility_id('5851').click()124 windows = self.open_application().window_handles[1]125 driver_im = webdriver.Remote(str(url),126 desired_capabilities={"appTopLevelWindow": windows})127 self.open_application().switch_to.window(windows)128 driver_im.find_element_by_accessibility_id('5077').clear()129 driver_im.find_element_by_accessibility_id('5077').send_keys(subject)130 driver_im.find_element_by_accessibility_id('5284').send_keys(content)131 driver_im.find_element_by_accessibility_id('5278').click()132 driver_im.find_element_by_accessibility_id('1').click()133 driver_im.find_element_by_accessibility_id('5281').click()134 try:135 driver_im.find_element_by_xpath(136 "//*[@Name='" + user_received_im + " is Unavailable. Please try again later.']").is_displayed()137 logger.info("Message sent failed because user aren't online. Please try again later.")138 raise AssertionError("Message sent failed because user aren't online. Please try again later.")139 except NoSuchElementException:140 try:141 driver_im.find_element_by_xpath(142 "//*[@Name='" + user_received_im + " is Unknown. Please check the address and try again.']").is_displayed()143 logger.info("Message sent failed because aren't exist. Please try again later.")144 raise AssertionError("Message sent failed because aren't exist. Please try again later.")145 except NoSuchElementException:146 pass147 logger.info('Message sent successfully')148 sleep(3)149 @keyword("Reply IM")150 def reply_im(self, subject_reply, content_reply):151 windows = self.remote().window_handles[1]152 driver_im = webdriver.Remote(str(remote),153 desired_capabilities={"appTopLevelWindow": windows})154 self.remote().switch_to.window(windows)155 try:156 driver_im.find_element_by_accessibility_id('5077').send_keys(subject_reply)157 driver_im.find_element_by_accessibility_id('5284').send_keys(content_reply)158 driver_im.find_element_by_accessibility_id('5281').click()159 except NoSuchElementException:160 raise AssertionError("Can't reply the message. Please try again")161 @keyword("Check IM")162 def check_im(self, content):163 windows = self.remote().window_handles[1]164 driver_im = webdriver.Remote(str(remote),165 desired_capabilities={"appTopLevelWindow": windows})166 self.remote().switch_to.window(windows)167 try:168 driver_im.find_element_by_xpath("//*[@Name='" + content + "']").is_displayed()169 except NoSuchElementException:170 raise AssertionError("The message was sent incorrectly")171 @keyword("Make a call to other user")172 def make_a_call(self, user_received_call, subject=''):173 self.open_application().find_element_by_accessibility_id('5352').click()174 windows = self.open_application().window_handles[1]175 driver_make_a_call = webdriver.Remote(str(url),176 desired_capabilities={"appTopLevelWindow": windows})177 self.open_application().switch_to.window(windows)178 driver_make_a_call.find_element_by_accessibility_id('5821').clear()179 driver_make_a_call.find_element_by_accessibility_id('5821').send_keys(user_received_call)180 driver_make_a_call.find_element_by_accessibility_id('1001').send_keys(subject)181 driver_make_a_call.find_element_by_accessibility_id('5846').click()182 windows = self.open_application().window_handles[1]183 driver_make_a_call = webdriver.Remote(str(url),184 desired_capabilities={"appTopLevelWindow": windows})185 self.open_application().switch_to.window(windows)186 logger.info("Calling to " + user_received_call)187 # driver_make_a_call.find_element(By.NAME, 'Close').click()188 # logger.info("Make a call successfully")189 @keyword("Received a call in remote machine")190 def received_a_call(self):191 windows = self.remote().window_handles[1]192 driver_received_a_call = webdriver.Remote(str(remote),193 desired_capabilities={"appTopLevelWindow": windows})194 self.remote().switch_to.window(windows)195 driver_received_a_call.find_element_by_accessibility_id('5181').click()196 logger.info("Call is established between 2 users")197 sleep(3)198 @keyword("Hold call")199 def hold_call(self):200 try:201 windows = self.open_application().window_handles[1]202 driver_make_a_call = webdriver.Remote(str(url),203 desired_capabilities={"appTopLevelWindow": windows})204 self.open_application().switch_to.window(windows)205 driver_make_a_call.implicitly_wait(10)206 driver_make_a_call.find_element_by_accessibility_id('5165').click()207 logger.info("Call on hold")208 except NoSuchElementException:209 raise AssertionError("Can't hold call")210 @keyword("Unhold call")211 def unhold_call(self):212 try:213 windows = self.open_application().window_handles[1]214 driver_make_a_call = webdriver.Remote(str(url),215 desired_capabilities={"appTopLevelWindow": windows})216 self.open_application().switch_to.window(windows)217 driver_make_a_call.implicitly_wait(10)218 driver_make_a_call.find_element_by_accessibility_id('5165').click()219 logger.info("Cancel on hold")220 sleep(2)221 except NoSuchElementException:222 raise AssertionError("Cant unhold call")223 @keyword("End call")224 def end_call(self):225 windows = self.open_application().window_handles[1]226 driver_make_a_call = webdriver.Remote(str(url),227 desired_capabilities={"appTopLevelWindow": windows})228 self.open_application().switch_to.window(windows)229 driver_make_a_call.find_element_by_accessibility_id('5164').click()230 windows = self.open_application().window_handles[1]231 driver_make_a_call = webdriver.Remote(str(url),232 desired_capabilities={"appTopLevelWindow": windows})233 driver_make_a_call.find_element(By.NAME, 'Close').click()234 logger.info("Call ended")235 @keyword("Search GAB")236 def search_gab(self, type_search, input_text):237 self.open_application().find_element_by_accessibility_id('5355').click()238 self.open_application().find_element_by_accessibility_id('5924').click()239 self.open_application().find_element(By.NAME, 'Global Address Book').click()240 try:241 if type_search == 'Name' or 'First Name' or 'Last Name' or 'Phone Number' or 'SIP Address':242 self.open_application().find_element_by_accessibility_id('5927').click()243 self.open_application().find_element(By.NAME, type_search).click()244 except NoSuchElementException:245 raise AssertionError("Error! Please re-enter the search type")246 self.open_application().find_element_by_accessibility_id('5926').clear()247 self.open_application().find_element_by_accessibility_id('5926').send_keys(input_text)248 self.open_application().find_element_by_accessibility_id('5928').click()249 logger.info("Search successfully!!!")250 @keyword("Add 1 contact")251 def add_a_contact(self, user_added):252 self.open_application().find_element_by_accessibility_id('5929').click()253 try:254 self.open_application().find_element(By.NAME, user_added + "@dsn.mil").click()255 except NoSuchElementException:256 raise AssertionError("Not found user!!!")257 self.open_application().find_element_by_accessibility_id('5914').click()258 windows = self.open_application().window_handles[1]259 driver_add_contact = webdriver.Remote(str(url),260 desired_capabilities={"appTopLevelWindow": windows})261 self.open_application().switch_to.window(windows)262 try:263 driver_add_contact.find_element_by_accessibility_id('5897').click()264 logger.info("Add " + user_added + " to contact successfully")265 except NoSuchElementException:266 driver_add_contact.find_element_by_accessibility_id('5898').click()267 raise AssertionError("User " + user_added + " already exists in contact")268 @keyword("Login to UCC")269 def login_ucc(self, password):270 try:271 self.open_application().find_element_by_accessibility_id('2').click()272 except NoSuchElementException:273 pass274 self.open_application().find_element_by_accessibility_id('5373').click()275 try:276 self.open_application().find_element_by_accessibility_id('5336').clear()277 self.open_application().find_element_by_accessibility_id('5336').send_keys(password)278 self.open_application().find_element_by_accessibility_id('5341').click()279 except NoSuchElementException:280 pass281 try:282 self.open_application().find_element_by_accessibility_id('6').click()283 except NoSuchElementException:284 pass285 try:286 self.open_application().find_element_by_accessibility_id('1').click()287 self.open_application().find_element_by_accessibility_id('1').click()288 self.open_application().find_element_by_accessibility_id('1').click()289 except NoSuchElementException:290 pass291 logger.info('Login successful')292 @keyword("Logout")293 def logout(self):294 try:295 self.open_application().find_element_by_accessibility_id('5373').click()296 except NoSuchElementException:297 pass298 try:299 windows = self.open_application().window_handles[1]300 driver1 = webdriver.Remote(str(url),301 desired_capabilities={"appTopLevelWindow": windows})302 driver1.find_element(By.NAME, 'Close').click()303 except IndexError:304 pass305 try:306 self.quit_application()307 except NoSuchElementException:308 pass309 @keyword("Logout remote")310 def logout_remote(self):311 try:312 self.remote().find_element_by_accessibility_id('5373').click()313 except NoSuchElementException:314 pass315 try:316 windows = self.remote().window_handles[1]317 driver1 = webdriver.Remote(str(remote),318 desired_capabilities={"appTopLevelWindow": windows})319 driver1.find_element(By.NAME, 'Close').click()320 except IndexError:321 pass322 try:323 self.quit_application_remote()324 except NoSuchElementException:325 pass326 @keyword("Login to UCC in remote machine")327 def login_ucc_remote(self, password):328 try:329 self.remote().find_element_by_accessibility_id('2').click()330 except NoSuchElementException:331 pass332 self.remote().find_element_by_accessibility_id('5373').click()333 try:334 self.remote().find_element_by_accessibility_id('5336').clear()335 self.remote().find_element_by_accessibility_id('5336').send_keys(password)336 self.remote().find_element_by_accessibility_id('5341').click()337 except NoSuchElementException:338 pass339 try:340 self.remote().find_element_by_accessibility_id('6').click()341 except NoSuchElementException:342 pass343 try:344 self.remote().find_element_by_accessibility_id('1').click()345 self.remote().find_element_by_accessibility_id('1').click()346 self.remote().find_element_by_accessibility_id('1').click()347 except NoSuchElementException:348 pass349 logger.info('Login successful')350 @keyword("Clean Up")351 def cleanup(self):352 try:353 logger.info("Collect logs and take screenshot")354 basicfunc.take_screenshot(self, self.driver)355 # self.driver.close()356 except (NoSuchElementException, TimeoutException, WebDriverException) as error:357 logger.error(('Clean up failure %s') % (error))358 @keyword("Screenshot and Clean Up")359 def screenshot(self):360 screenshot = ImageGrab.grab(all_screens=True)361 save_path = base_path+ "Screenshot-" + datetime.now().strftime(362 "%Y-%m-%d_%H%M%S") + ".png"363 screenshot.save(save_path)364 try:365 self.open_application().find_element_by_accessibility_id('5373').click()366 except NoSuchElementException:367 pass368 try:369 windows = self.open_application().window_handles[1]370 driver1 = webdriver.Remote(str(url),371 desired_capabilities={"appTopLevelWindow": windows})372 driver1.find_element(By.NAME, 'Close').click()373 except IndexError:374 pass375 try:376 self.quit_application()377 except NoSuchElementException:378 pass379 try:380 self.remote().find_element_by_accessibility_id('5353').is_displayed()381 try:382 self.remote().find_element_by_accessibility_id('5373').click()383 except NoSuchElementException:...

Full Screen

Full Screen

application.py

Source:application.py Github

copy

Full Screen

1from talon.voice import Context, Key, Str, ui2import time3ctx = Context('application_launcher')4# will launch if not already open5def open_application(application):6 def open_or_switch(m):7 ui.launch(bundle=application)8 return open_or_switch9# get bundle: osascript -e 'id of app "app-name"'10keymap = {11 '(stratum|application adam)': open_application('com.github.atom'),12 'application activity': open_application('com.apple.ActivityMonitor'),13 '(chromie|application chrome)': open_application('com.google.Chrome'),14 'application code': open_application('com.microsoft.VSCode'),15 'application developer': open_application('org.mozilla.firefoxdeveloperedition'),16 'application doctor': open_application('com.docker.docker'),17 'application firefox': open_application('org.mozilla.firefox'),18 '(termite|application I term)': open_application('com.googlecode.iterm2'),19 '(chatter|application (message|messages))': open_application('com.apple.iChat'),20 'application music': open_application('com.apple.iTunes'),21 'application reminder': open_application('com.apple.reminders'),22 'application skype': open_application('com.skype.skype'),23 '(slacker|application slacker)': open_application('com.tinyspeck.slackmacgap'),24 'application sublime': open_application('com.sublimetext.3'),25 'application terminal': open_application('com.apple.Terminal'),26 'application text': open_application('com.apple.TextEdit'),27 'application video': open_application('org.videolan.vlc'),28 'application tree': open_application('com.torusknot.SourceTreeNotMAS'),29 '(zeppelin|application zeppelin)': open_application('io.zeplin.osx'),30 'application zoom': open_application('us.zoom.xos'),31 'preffies': Key('cmd-,'),32 'marco': Key('cmd-f'),33 'marco project': Key('cmd-shift-f'),34 'marco select': Key('cmd-e cmd-f enter'),35 'marco next': Key('cmd-g'),36 'marco last': Key('cmd-shift-g'),37 'run stacks': Key('ctrl-alt-d'),38}...

Full Screen

Full Screen

python typer.py

Source:python typer.py Github

copy

Full Screen

...15 keyboard.press(char)16 keyboard.release(char)17 time.sleep(time_between_keystrokes)18 19 def open_application(app: str):20 kf.press_keycode(Key.cmd)21 time.sleep(.1)22 kf.type_string(app)23 time.sleep(.1)24 kf.press_keycode(Key.enter)25 time.sleep(.2)26kf = Key_Functions27def notepad_typer():28 kf.open_application("notepad")29 # Now notepad is open.30 kf.realistic_typing_string("Whatever you'd like to type to the user.", 0.05)31def cmd_open():32 kf.open_application("cmd")33 time.sleep(.1)34 # Now cmd is open, not in admin though :(35 kf.realistic_typing_string("color a && cls && cmd")36 kf.press_keycode(Key.enter)37 time.sleep(.1)38 kf.type_string("tree")39 kf.press_keycode(Key.enter)40# notepad_typer()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-appiumlibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful