Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

support send keys to active_element#707

Closed
Chris8711 wants to merge 3 commits intoappium:masterappium/python-client:masterfrom
Chris8711:masterChris8711/python-client:masterCopy head branch name to clipboard
Closed

support send keys to active_element#707
Chris8711 wants to merge 3 commits intoappium:masterappium/python-client:masterfrom
Chris8711:masterChris8711/python-client:masterCopy head branch name to clipboard

Conversation

@Chris8711
Copy link

add a mixin class ActiveElement
support function get_active_element and send_keys_to_active_element

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 1, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

"""
try:
return self.execute(W3C_Command.W3C_GET_ACTIVE_ELEMENT)['value']
except NoSuchElementException:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is ok to throw the exception from this method: https://www.w3.org/TR/webdriver/#dfn-get-active-element

except NoSuchElementException:
return None

def send_keys_to_active_element(self, value: str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any actual point in this helper method. also, it is not a part of the spec

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the driver.tap([positions]) will actually click some element

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use other tool the get the position on the screenshot.
and use appium client to tap or click the screen.
if some element was tapped. Then I can use get_active_element to do other things

@mykola-mokhnach
Copy link
Contributor

I can observe that selenium python lib already has a wrapper for active element:

class SwitchTo:
    def __init__(self, driver):
        import weakref
        self._driver = weakref.proxy(driver)

    @property
    def active_element(self) -> WebElement:
        """
        Returns the element with focus, or BODY if nothing has focus.

        :Usage:
            ::

                element = driver.switch_to.active_element
        """
        return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)['value']

Wouldn't this be a duplicate then?

@Chris8711
Copy link
Author

I can observe that selenium python lib already has a wrapper for active element:

class SwitchTo:
    def __init__(self, driver):
        import weakref
        self._driver = weakref.proxy(driver)

    @property
    def active_element(self) -> WebElement:
        """
        Returns the element with focus, or BODY if nothing has focus.

        :Usage:
            ::

                element = driver.switch_to.active_element
        """
        return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)['value']

Wouldn't this be a duplicate then?

yes. I haven't noticed that.
Thank you

@Chris8711
Copy link
Author

this is duplicated

@Chris8711 Chris8711 closed this Apr 1, 2022
@KazuCocoa
Copy link
Member

KazuCocoa commented Apr 1, 2022

Btw, sending keys to an active element is now W3C's send_keys action.
appium/appium#16419 (comment)

Get an active element -> calling send_keys to the element is also the same, but the w3c action's one is old send_keys_active_element ([:post, 'session/:session_id/keys']) endpoint alternative in W3C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.