in Education by
I've had several occasions in my selenium tests where I decided to use Selenium's click_and_hold() (source code here) method on some element. The source code makes it look like it will stay pressed indefinitely but there are definitely some actions, such as a simple click, that cause the held click to be released. Obviously calling release will release the held click too, but does anyone have a grasp on exactly what actions/conditions (either from the script or the page itself) will cause the held click to be released? I've linked to the documentation for the python bindings, but I assume this would be the same no matter what language is used to write the script. Please let me know if this assumption is incorrect! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
release() release(on_element) releases a held mouse button on an element. If on_element is None releases on current mouse position which is defined as: def release(self, on_element=None): """ Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.release() self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute(Command.MOUSE_UP, {})) return self release() is invoked by default by different methods of the ActionChains implementation. Some of them are as follows: release(): Releasing a held mouse button on an element. drag_and_drop(source, target): Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button. drag_and_drop_by_offset(source, xoffset, yoffset): Holds down the left mouse button on the source element, then moves to the target offset and releases the mouse button. click_and_hold() click_and_hold() holds down the left mouse button on an element. So you saw it right, the source code confirms the same that it will stay pressed indefinitely unless release() is directly invoked or invoked through other methods. However there can be other actions / events which may cause the hold down left mouse button to be released implicitly. These actions / events can be a result of any of the HTML DOM Events. HTML DOM events allow JavaScript / AjaxCalls to register different event handlers on elements in an HTML document. Some of the mostly encountered events are: HTML DOM UiEvent: Events that are triggered from the user interface belongs to the UiEvent Object. onload Event: The onload event occurs when an object has been loaded. onresize Event: The onresize event occurs when the browser window has been resized. onscroll Event: The onscroll event occurs when an element's scrollbar is being scrolled. HTML DOM FocusEvent: Events that occur when elements gets or loses focus, belongs to the FocusEvent Object. onblur Event: The event occurs when an element loses focus onfocus Event: The event occurs when an element gets focus onfocusin Event: The event occurs when an element is about to get focus onfocusout Event: The event occurs when an element is about to lose focus The Event Object: All event objects in the DOM are based on the Event Object. onchange Event: The onchange event occurs when the value of an element has been changed. HTML DOM MouseEvent: Events that occur when the mouse interacts with the HTML document belongs to the MouseEvent Object. onmousedown Event: The onmousedown event occurs when a user presses a mouse button over an element. onmouseup Event: The onmouseup event occurs when a user releases a mouse button over an element. HTML DOM DragEvent: Events that occur when elements are dragged and/or dropped, belongs to the DragEvent Object. ondrag Event: The ondrag event occurs when an element or text selection is being dragged. ondragstart Event: The ondragstart event occurs when the user starts to drag an element or text selection. HTML DOM TransitionEvent: Events that occur when a CSS transition runs, belongs to the TransitionEvent Object. transitionend Event: The event occurs when a CSS transition has completed key_up() The key_up() method also releases a modifier key. As an example: ActionChains(driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform() This usecase Without any visibility to your usecase of implementing click_and_hold() it is to be noted that, key_down() is a method which performs a modifier key press and it does not release the modifier key and subsequent interactions may assume it's kept pressed. Note that the modifier key is never released implicitly. Either key_up(theKey) or send_keys(Keys.NULL) must be called to release the modifier.

Related questions

0 votes
    Which of these methods will respond when you click any button by mouse? (a) mouseClicked() (b) mouseEntered( ... Event Handling of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these methods will respond when you click any button by mouse? (a) mouseClicked() (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 7, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Basically what the title says... I need to have an image that when clicked, I call script.php for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Explain Mouse Click and Global Send Keys in Blue Prism?...
asked Nov 6, 2020 in Technology by JackTerrance
0 votes
    After reading the switch-to-iframe documentation, I am still not sure what will driver.getPageSource() ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Describe Release Train Engineer 2 actions...
asked Nov 30, 2020 in Technology by Editorial Staff
0 votes
    we have RecyclerView with list of children songs, when you click on a song it takes you to another ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    State true or false. When you have finished your work in the IMG or ABAP Workbench, or have reached a certain stage, you can release the request. A. True B. False...
asked Feb 20, 2023 in Technology by JackTerrance
...