@@ -571,7 +571,7 @@ def click_link(self, locator, modifier=False):
571571 self ._click_with_modifier (locator , ['link' , 'link' ], modifier )
572572
573573 @keyword
574- def click_element (self , locator , modifier = False ):
574+ def click_element (self , locator , modifier = False , action_chain = False ):
575575 """Click the element identified by ``locator``.
576576
577577 See the `Locating elements` section for details about the locator
@@ -586,18 +586,36 @@ def click_element(self, locator, modifier=False):
586586 [https://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html#selenium.webdriver.common.keys.Keys.ALT|ALT key]
587587 . If ``modifier`` does not match to Selenium Keys, keyword fails.
588588
589+ If ``action_chain`` argument is true, see `Boolean arguments` for more
590+ details on how to set boolean argument, then keyword uses ActionChain
591+ based click instead of the <web_element>.click() function. If both
592+ ``action_chain`` and ``modifier`` are defined, the click will be
593+ performed using ``modifier`` and ``action_chain`` will be ignored.
594+
589595 Example:
590- | Click Element | id:button | | # Would click element without any modifiers. |
591- | Click Element | id:button | CTRL | # Would click element with CTLR key pressed down. |
592- | Click Element | id:button | CTRL+ALT | # Would click element with CTLR and ALT keys pressed down. |
596+ | Click Element | id:button | | # Would click element without any modifiers. |
597+ | Click Element | id:button | CTRL | # Would click element with CTLR key pressed down. |
598+ | Click Element | id:button | CTRL+ALT | # Would click element with CTLR and ALT keys pressed down. |
599+ | Click Element | id:button | action_chain=True | # Clicks the button using an Selenium ActionChains |
593600
594601 The ``modifier`` argument is new in SeleniumLibrary 3.2
602+ The ``action_chain`` argument is new in SeleniumLibrary 4.1
595603 """
596- if is_falsy (modifier ):
604+ if is_truthy (modifier ):
605+ self ._click_with_modifier (locator , [None , None ], modifier )
606+ elif is_truthy (action_chain ):
607+ self ._click_with_action_chain (locator )
608+ else :
597609 self .info ("Clicking element '%s'." % locator )
598610 self .find_element (locator ).click ()
599- else :
600- self ._click_with_modifier (locator , [None , None ], modifier )
611+
612+ def _click_with_action_chain (self , locator ):
613+ self .info ("Clicking '%s' using an action chain." % locator )
614+ action = ActionChains (self .driver )
615+ element = self .find_element (locator )
616+ action .move_to_element (element )
617+ action .click ()
618+ action .perform ()
601619
602620 def _click_with_modifier (self , locator , tag , modifier ):
603621 self .info ("Clicking %s '%s' with %s." % (tag if tag [0 ] else 'element' , locator , modifier ))
0 commit comments