Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add flutter integration driver commands and tests #1022

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

MummanaSubramanya
Copy link

@KazuCocoa
Copy link
Member

KazuCocoa commented Sep 19, 2024

Could you add tests in unit test as possible instead of functional test?
https://github.com/appium/python-client/tree/master/test/unit

As a client, what http request should be sent is important but it does not need to test driver side. Driver's response can be a mock.

Existing functional tests include tests for appium project's drivers themselves. They would be removed as not necessary for client tests.

@KazuCocoa
Copy link
Member

KazuCocoa commented Sep 19, 2024

Could you use flutter_intergation namespace or flutter/flutter_integration?

appium/webdriver/common/flutterby.py Outdated Show resolved Hide resolved
appium/webdriver/flutter_finder.py Outdated Show resolved Hide resolved
appium/webdriver/extensions/flutter/flutter_commands.py Outdated Show resolved Hide resolved
appium/webdriver/extensions/flutter/flutter_commands.py Outdated Show resolved Hide resolved
appium/webdriver/flutter_finder.py Outdated Show resolved Hide resolved
appium/webdriver/extensions/flutter/flutter_commands.py Outdated Show resolved Hide resolved
@KazuCocoa
Copy link
Member

I left some comments.

  • convert tests to unit test to focus on each client method's input/output (fast and less flakiness as client)
    • Existing unit test should help to see how to check the http request's input/output as a client
  • name space
  • some code improvement

Thank you for the contribution, btw :)

None:
"""
if isinstance(locator, WebElement):
opts = {'element': locator, 'timeout': time_out}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we actually pass the element object itself or its identifier?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Sep 20, 2024

Choose a reason for hiding this comment

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

I am not sure it is going to work like that. Could you please point me to a passing e2e test that verifies this approach?

Copy link
Author

@MummanaSubramanya MummanaSubramanya Sep 20, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks. I mean I would like to check the github actions log where the test has passed

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently all flutter tests fail with https://github.com/appium/python-client/actions/runs/10966892515/job/30463953515?pr=1022#step:17:76

You may verify they work as expected by running tests in the local fork

@MummanaSubramanya
Copy link
Author

Could you use flutter_intergation namespace or flutter/flutter_integration?

updated

# specific language governing permissions and limitations
# under the License.

from typing import Dict
Copy link
Contributor

Choose a reason for hiding this comment

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

please apply black and isort formatting

Copy link
Author

Choose a reason for hiding this comment

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

thanks! Applied for all files

UP = 'up'
DOWN = 'down'

def as_string(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

this method is not really needed. You may use .value

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

was the change committed?

def to_dict(self) -> dict:
return { 'using': self.using, 'value': self.value}

def as_args(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

tuple[str, str]

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! fixed

from appium.webdriver.webelement import WebElement


class FlutterCommand:
Copy link
Contributor

Choose a reason for hiding this comment

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

How about renaming this class to FlutterExtensions?

Copy link
Author

Choose a reason for hiding this comment

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

FlutterExtensions sounds more generic and doesn't immediately convey that it's about commands or actions.
I would rather like to stick with same name or FlutterActions. Please suggest

Copy link
Contributor

Choose a reason for hiding this comment

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

That's just a proposal. If you like Command more then let it be

scrollView (str): The view of the scroll.
delta (int): delta for the scroll
maxScrolls (int): Max times to scroll
settleBetweenScrollsTimeout (int): settle timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention explicitly the time unit used there (I assume milliseconds) and default values if not provided

Copy link
Author

Choose a reason for hiding this comment

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

fixed and added the default values

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, I still cannot find neither for KeywordArgs

Scrolls until the specified element becomes visible.
Args:
scroll_to (FlutterFinder): The Flutter element to scroll to.
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Sep 20, 2024

Choose a reason for hiding this comment

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

there is no need to repeat types in docstrings

Copy link
Author

Choose a reason for hiding this comment

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

are you suggesting me to remove (FlutterFinder)?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, do it for all args where the time is set explicitly upon declaration

@@ -25,3 +25,8 @@ class AppiumBy(By):
ACCESSIBILITY_ID = 'accessibility id'
IMAGE = '-image'
CUSTOM = '-custom'
FLUTTER_INTEGRATION_SEMANTICS_LABEL = '-flutter semantics label'
Copy link
Member

Choose a reason for hiding this comment

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

👍

Can you leave a link as a comment for those as not in appium org repo for future maintenance?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Could you please clarify link I should add in comment .

Copy link
Member

Choose a reason for hiding this comment

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

I think the driver project's GitHub repo is good

else:
opts['locator'] = locator.to_dict()
if time_out is not None:
opts['timeout'] = time_out
Copy link
Contributor

Choose a reason for hiding this comment

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

does the downstream API also accept float seconds or should we provide integer milliseconds instead?

None:
"""
opts: Dict[str, Union[WebElement, Dict[str, str], float]] = {}
if isinstance(locator, WebElement):
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition is duplicated multiple times. Please extract it to a function

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