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

Changed find_by_name to find_by_xpath in fill() #1100

Closed
wants to merge 1 commit into from

Conversation

riddhikt
Copy link

@riddhikt riddhikt commented Oct 4, 2022

When dealing with a page where the name is set dynamically we were not able to use fill() or attach_file() as it was accepting name as a parameter, so changed it to xpath as we can always get a xpath which is unique

When dealing with a page where the name is set dynamically we were not able to use fill() or attach_file() as it was accepting name as a parameter, so changed it to xpath as we can always get a xpath which is unique
Comment on lines +561 to +562
def fill(self, xpath, value):
field = self.find_by_xpath(xpath).first
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be a breaking change and would make the API inconsistent, so it's unlikely that we'll merge it. We could introduce something like fill_by_xpath, but I'd like to hear from others before we move forward with an addition to the API.

@andrewsmedina @jsfehler any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that's the wrong direction. I'm in favour of removing browser.fill() entirely.

browser.fill("foo", "bar") is always going to be difficult to read. It's too opaque.

browser.find_by_xpath("foo").fill("bar") is easier to read and more explicit.

If we want an implicit find function, it should look like:
browser.find("foo").fill("bar")

browser.find(xpath="foo").fill("bar")

It should default to CSS, accept other strategies as arguments, and be configurable to default to other strategies.

Copy link
Author

Choose a reason for hiding this comment

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

I agree with @jsfehler the solution i gave looks temporary and it is also opaque, we should implement something like browser.find_by_xpath("foo").fill("bar") and same for attach_file()

@jsfehler
Copy link
Collaborator

With #933 merged in, I don't see this PR as necessary anymore.

@jsfehler jsfehler closed this Feb 13, 2024
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.

None yet

3 participants