-
Notifications
You must be signed in to change notification settings - Fork 777
Unify "index" type of keyword arguments. #1799
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
Conversation
no tests have been written nor executed .. |
create_webdriver was marked as returning a str, however, its return value is coming from register_driver which is documented to return int. These where changed to return actual int. switch_driver was only accepting str as "index_or_alias". While aliases are str's since create_driver now returns the actual index as int, accepting both types makes more sense. select and unselect list keywords where typehinted to receive only str as index type - when called from python side, this does not make much sense so changed those to int as RF should do type conversion automatically. Fixes #1791
One overarching thought is I would want this to be backwards compatible. Such that this change does not force people to change all their select from list by index calls. So I would want the Robot Type conversion from the robot side to take those strings and automatically convert those to ints in all cases that switch from incoming str to incoming int. Adding some inline comments as well .. |
@@ -133,7 +133,7 @@ class SeleniumLibrary: | |||
def select_all_from_list(self, locator: Union[selenium.webdriver.remote.webelement.WebElement, str]): ... | |||
def select_checkbox(self, locator: Union[selenium.webdriver.remote.webelement.WebElement, str]): ... | |||
def select_frame(self, locator: Union[selenium.webdriver.remote.webelement.WebElement, str]): ... | |||
def select_from_list_by_index(self, locator: Union[selenium.webdriver.remote.webelement.WebElement, str], *indexes: str): ... | |||
def select_from_list_by_index(self, locator: Union[selenium.webdriver.remote.webelement.WebElement, str], *indexes: int): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be Union[str, int]
for Robot to do the type conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if robot core does not do the type conversion I would be fine with both
Union[str, int] as the argument type and then inrternally in all spots needed, something like
if isinstance(indexes, str):
int(indexes)
.. although now I see these can be and are *indexes and not index, meaning it could be multiple indexes .. thus complicating my conversion strategy a bit ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Noting these comments apply to all instances of these str to ints]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corner cases are not know but rf will do type conversion to int
Union is used only for with alias_or_index because alias is user defined string bu index is int returned by create_driver and register_driver
Don't have time to review this right now, but I have one possible idea related to this. We recently changed Robot's Process library to return actual process objects, not handles (e.g. ints), and it has worked great. Could |
create_webdriver was marked as returning a str, however, its return value is coming from register_driver which is documented to return int. These where changed to return actual int.
switch_driver was only accepting str as "index_or_alias". While aliases are str's since create_driver now returns the actual index as int, accepting both types makes more sense.
select and unselect list keywords where typehinted to receive only str as index type - when called from python side, this does not make much sense so changed those to int as RF should do type conversion automatically.
Fixes #1791