Skip to content

chore: Update comments to locator patches#724

Merged
KazuCocoa merged 4 commits intoappium:masterfrom
VladimirPodolian:patch-1
Jun 15, 2022
Merged

chore: Update comments to locator patches#724
KazuCocoa merged 4 commits intoappium:masterfrom
VladimirPodolian:patch-1

Conversation

@VladimirPodolian
Copy link
Copy Markdown
Contributor

@VladimirPodolian VladimirPodolian commented Jun 13, 2022

Hi! I faced with an issue while using appium.find_element with locators, that I used for my selenium tests. Is it possible to uncomment that block and use him in web view context only ?

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jun 13, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@mykola-mokhnach
Copy link
Copy Markdown
Contributor

Each call to self.context creates extra HTTP request to Appium server, which could significantly slow down automated tests. Unfortunately we cannot merge this PR

Copy link
Copy Markdown
Contributor

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

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

see the above comment

@KazuCocoa
Copy link
Copy Markdown
Member

This one should work accurately when autoWebview is enabled, without explicit set context, for example.

@VladimirPodolian
Copy link
Copy Markdown
Contributor Author

VladimirPodolian commented Jun 13, 2022

@mykola-mokhnach Hi, and thank you for answer.
Maybe it's possible to pass that as class argument for both classes?

For WebDriver:

class WebDriver(...):
    def __init__(command_executor, desired_capabilities, ..., selenium_compatibility)
        ...
        self.selenium_compatibility = selenium_compatibility

    ...

    def find_element():
            if self.selenium_compatibility:
                if by == By.ID:
                    ...

    ...

For WebElement (need to define __init__)

class WebElement(AppiumWebElementSearchContext):
    def __init__(self, selenium_compatibility=False):
        self.selenium_compatibility = selenium_compatibility

    ...
    
    def find_element():
            if self.selenium_compatibility:
                if by == By.ID:
                    ...

    ...

Or only for WebDriver, even you don't accept the specifying the __init__ in WebElement

@mykola-mokhnach
Copy link
Copy Markdown
Contributor

This has nothing to do with selenium compatibility. Selenium itself has this code as a workaround to support legacy non-w3c compatible locators (the standard only defines css and xpath locator types).

To be honest I'm not very happy about keeping these workarounds here as locators id/name locator types are not going to be supported anyway, which encourages customers to update their tests instead of having the legacy stuff forever.

In the worst case it is possible to do the same id/name -> css conversion directly in the client code with the same success.

@VladimirPodolian
Copy link
Copy Markdown
Contributor Author

@mykola-mokhnach Understood. But what is the final decision here? You don't want to have this "Selenium workaround" in your own code, but it's commented right now. Can I just delete this "comment section" in this PR and do a self workaround in my side?

@KazuCocoa
Copy link
Copy Markdown
Member

The comment-out (TODO mark) was still we were learning selenium in the past.

The TODO comment can be removed, but I need the comment-out ones to keep the diff about the workaround for future updates so far, so please keep the comment-out itself so far.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jun 14, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@VladimirPodolian VladimirPodolian changed the title Selenium locator type compatibility for web view Updates of disorientating comments Jun 14, 2022
@mykola-mokhnach mykola-mokhnach changed the title Updates of disorientating comments chore: Update comments to locator patches Jun 14, 2022
@KazuCocoa KazuCocoa merged commit 0fcea82 into appium:master Jun 15, 2022
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