How to use get_window_position method in AutoItDriverServer

Best Python code snippet using AutoItDriverServer_python

window_tests.py

Source:window_tests.py Github

copy

Full Screen

...48 new_size = driver.get_window_size()49 assert new_size.get('width') == target_width50 assert new_size.get('height') == target_height51def test_should_get_the_position_of_the_current_window(driver):52 position = driver.get_window_position()53 assert position.get('x') >= 054 assert position.get('y') >= 055def test_should_set_the_position_of_the_current_window(driver):56 position = driver.get_window_position()57 target_x = position.get('x') + 1058 target_y = position.get('y') + 1059 driver.set_window_position(x=target_x, y=target_y)60 WebDriverWait(driver, 2).until(lambda d: d.get_window_position()['x'] != position['x'] and61 d.get_window_position()['y'] != position['y'])62 new_position = driver.get_window_position()63 assert new_position.get('x') == target_x64 assert new_position.get('y') == target_y65@pytest.mark.xfail_chrome(raises=WebDriverException,66 reason='Get Window Rect command not implemented')67@pytest.mark.xfail_firefox(raises=WebDriverException,68 reason='Get Window Rect command not implemented')69@pytest.mark.xfail_phantomjs(raises=WebDriverException,70 reason='Get Window Rect command not implemented')71@pytest.mark.xfail_remote(raises=WebDriverException,72 reason='Get Window Rect command not implemented')73@pytest.mark.xfail_safari(raises=WebDriverException,74 reason='Get Window Rect command not implemented')75def test_should_get_the_rect_of_the_current_window(driver):76 rect = driver.get_window_rect()77 assert rect.get('x') >= 078 assert rect.get('y') >= 079 assert rect.get('width') >= 080 assert rect.get('height') >= 081@pytest.mark.xfail_chrome(raises=WebDriverException,82 reason='Get Window Rect command not implemented')83@pytest.mark.xfail_firefox(raises=WebDriverException,84 reason='Get Window Rect command not implemented')85@pytest.mark.xfail_phantomjs(raises=WebDriverException,86 reason='Get Window Rect command not implemented')87@pytest.mark.xfail_remote(raises=WebDriverException,88 reason='Get Window Rect command not implemented')89@pytest.mark.xfail_safari(raises=WebDriverException,90 reason='Get Window Rect command not implemented')91def test_should_set_the_rect_of_the_current_window(driver):92 rect = driver.get_window_rect()93 target_x = rect.get('x') + 1094 target_y = rect.get('y') + 1095 target_width = rect.get('width') + 1096 target_height = rect.get('height') + 1097 driver.set_window_rect(x=target_x, y=target_y, width=target_width, height=target_height)98 WebDriverWait(driver, 2).until(lambda d: d.get_window_position()['x'] != rect['x'] and99 d.get_window_position()['y'] != rect['y'])100 new_rect = driver.get_window_rect()101 assert new_rect.get('x') == target_x102 assert new_rect.get('y') == target_y103 assert new_rect.get('width') == target_width104 assert new_rect.get('height') == target_height105@pytest.mark.xfail_chrome(raises=WebDriverException,106 reason='Fullscreen command not implemented')107@pytest.mark.xfail_firefox(raises=WebDriverException,108 reason='Fullscreen command not implemented')109@pytest.mark.xfail_phantomjs(raises=WebDriverException,110 reason='Fullscreen command not implemented')111@pytest.mark.xfail_remote(raises=WebDriverException,112 reason='Fullscreen command not implemented')113@pytest.mark.xfail_safari(raises=WebDriverException,...

Full Screen

Full Screen

test_window_position.py

Source:test_window_position.py Github

copy

Full Screen

...5from marionette_harness import MarionetteTestCase6class TestWindowPosition(MarionetteTestCase):7 def setUp(self):8 MarionetteTestCase.setUp(self)9 self.original_position = self.marionette.get_window_position()10 def tearDown(self):11 x, y = self.original_position["x"], self.original_position["y"]12 self.marionette.set_window_position(x, y)13 MarionetteTestCase.tearDown(self)14 def test_get_types(self):15 position = self.marionette.get_window_position()16 self.assertIsInstance(position["x"], int)17 self.assertIsInstance(position["y"], int)18 def test_set_types(self):19 for x, y in (["a", "b"], [1.2, 3.4], [True, False], [[], []], [{}, {}]):20 print("testing invalid type position ({},{})".format(x, y))21 with self.assertRaises(InvalidArgumentException):22 self.marionette.set_window_position(x, y)23 def test_setting_window_rect_with_nulls_errors(self):24 with self.assertRaises(InvalidArgumentException):25 self.marionette.set_window_rect(height=None, width=None,26 x=None, y=None)27 def test_set_position_with_rect(self):28 old_position = self.marionette.window_rect29 wanted_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}30 new_position = self.marionette.set_window_rect(x=wanted_position["x"], y=wanted_position["y"])31 self.assertNotEqual(old_position["x"], new_position["x"])32 self.assertNotEqual(old_position["y"], new_position["y"])33 def test_set_size_with_rect(self):34 actual = self.marionette.window_size35 width = actual["width"] - 5036 height = actual["height"] - 5037 size = self.marionette.set_window_rect(width=width, height=height)38 self.assertEqual(size["width"], width,39 "New width is {0} but should be {1}".format(size["width"], width))40 self.assertEqual(size["height"], height,41 "New height is {0} but should be {1}".format(size["height"], height))42 def test_move_to_new_position(self):43 old_position = self.marionette.get_window_position()44 new_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}45 self.marionette.set_window_position(new_position["x"], new_position["y"])46 self.assertNotEqual(old_position["x"], new_position["x"])47 self.assertNotEqual(old_position["y"], new_position["y"])48 def test_move_to_existing_position(self):49 old_position = self.marionette.get_window_position()50 self.marionette.set_window_position(old_position["x"], old_position["y"])51 new_position = self.marionette.get_window_position()52 self.assertEqual(old_position["x"], new_position["x"])53 self.assertEqual(old_position["y"], new_position["y"])54 def test_move_to_negative_coordinates(self):55 print("Current position: {}".format(56 self.marionette.get_window_position()))57 self.marionette.set_window_position(-8, -8)58 position = self.marionette.get_window_position()59 print("Position after requesting move to negative coordinates: {}".format(position))60 # Different systems will report more or less than (-8,-8)61 # depending on the characteristics of the window manager, since62 # the screenX/screenY position measures the chrome boundaries,63 # including any WM decorations.64 #65 # This makes this hard to reliably test across different66 # environments. Generally we are happy when calling67 # marionette.set_window_position with negative coordinates does68 # not throw.69 #70 # Because we have to cater to an unknown set of environments,71 # the following assertions are the most common denominator that72 # make this test pass, irregardless of system characteristics....

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 AutoItDriverServer 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