Conversation
Move the click to action chain instead of clicking it via regular element click. This keeps the actions atomic and also handles weird bug where the focus from text box jumps in legacy/older for various rendering reasons.
| if with_click: | ||
| actions.click(element) |
There was a problem hiding this comment.
This seems like a weird placement of theclick. Isn't the initial click needed for the input in the if-statement to work? 🤔
Also, the actions.click is fundamentally different from the element.click. So this might not be backwards compat.
I would keep the "old" click, and introduce a use_actions_for_click boolean that defaults to false.
Like so:
def enter_text(self, locator, text, with_click=True, with_clear=False, with_enter=False, params=None, use_actions_for_click=False):
element = locator
if not isinstance(element, WebElement):
element = self.get_visible_element(locator, params)
actions = ActionChains(self.driver)
if with_click:
if use_actions_for_click:
actions.click(element)
else:
element.click()
if 'explorer' in self.driver.name and "@" in str(text):
actions = BasePage.handle_at_sign_for_ie(text, actions)
else:
actions.send_keys_to_element(element, text)
if with_clear:
element.clear()
# Click to regain focus as clear does clear w/ blur by design -
# https://w3c.github.io/webdriver/webdriver-spec.html#element-clear
self.click(element)
if with_enter:
actions.send_keys(Keys.ENTER)
actions.perform()There was a problem hiding this comment.
I am curious about how it breaks the backward compatibility. The backward versions of selenium supports action chains send_keys but not click ? I agree the if placement can stay at where it is now.
There was a problem hiding this comment.
Oh, I didn't mean it breaks backwards compat with Selenium, I meant with the test suite. Originally, before this was a pip-package, the click was action chains. But that caused a lot of tests to be flaky due to some inconsistency in the AC implementation.
So you risk bringing that flakyness back by replacing the click. :)
Move the click to action chain instead of clicking it via regular element click. This keeps the actions atomic and also handles weird bug where the focus from text box jumps in legacy/older for various rendering reasons.