2727
2828from selenium import webdriver
2929from selenium .webdriver .support .wait import WebDriverWait
30- from selenium .webdriver .common .action_chains import ActionChains
30+ from selenium .webdriver .common .action_chains import ActionChains , Keys
3131from PIL import Image , ImageStat , ImageChops
3232
3333from midas_handler import MidasHandler
@@ -443,7 +443,7 @@ class BaseTest(TestCase):
443443 url = self .testBaseURL + url
444444 return self .driver .get (url )
445445
446- def drag (self , element , delta , offset = (0 , 0 )):
446+ def drag (self , element , delta , offset = (0 , 0 ), ctrlDown = False ):
447447 '''
448448 Drag the element given (by a CSS selector) starting
449449 at ``offset`` relative to the center of the element by
@@ -454,6 +454,7 @@ class BaseTest(TestCase):
454454 :type delta: [x, y]
455455 :param offset: The offset from the element center to start the drag.
456456 :type offset: [x, y]
457+ :param ctrlDown: if True, hold down control key during the drag.
457458
458459 For example,
459460
@@ -464,11 +465,15 @@ class BaseTest(TestCase):
464465 '''
465466 el = self .getElement (element )
466467 action = ActionChains (self .driver )
468+ if ctrlDown :
469+ action .key_down (Keys .CONTROL )
467470
468471 action .move_to_element_with_offset (el , offset [0 ], offset [1 ])
469472 action .click_and_hold ()
470473 action .move_by_offset (delta [0 ], delta [1 ])
471474 action .release ()
475+ if ctrlDown :
476+ action .key_up (Keys .CONTROL )
472477 action .perform ()
473478
474479 def hover (self , element , offset = (0 , 0 )):
0 commit comments