You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you want to focus an element in Pylenium, you either have to perform some random action on the element or use the Actions class from Selenium. Both work, but it's probably better to have a convenient method to achieve this.
# Current solutions which don't feel so great## Random actionpy.get("#button").hover()
---or---## Actions classelement=py.get("#button")
actions=Actions(py.webdriver)
actions.move_to_element(element).perform()
Solutions
I recommend adding a new .focus() method to our Element class instead!
Solution 1: Use Selenium's Action class
# Something like this under the Element classdeffocus(self) ->"Element":
actions=Actions(self.py.webdriver)
actions.move_to_element(self.webelement).perform()
returnself
Solution 2: Use javascript to do the focus
# Something like this under the Element classdeffocus(self) ->"Element":
javascript="js that does the focus"self.py.execute_script(javascript, self.webelement)
returnself
With a solution in place, focusing on an element feels much more explicit and makes sense 🎉
Problem
Currently, if you want to focus an element in Pylenium, you either have to perform some random action on the element or use the
Actions
class from Selenium. Both work, but it's probably better to have a convenient method to achieve this.Solutions
I recommend adding a new
.focus()
method to ourElement
class instead!Solution 1: Use Selenium's Action class
Solution 2: Use javascript to do the focus
With a solution in place, focusing on an element feels much more explicit and makes sense 🎉
The text was updated successfully, but these errors were encountered: