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

click and press methods #13

Closed
gcw07 opened this issue Sep 19, 2016 · 2 comments
Closed

click and press methods #13

gcw07 opened this issue Sep 19, 2016 · 2 comments
Labels

Comments

@gcw07
Copy link

gcw07 commented Sep 19, 2016

OK, I've been playing around with both of these methods and how it searches through xpath. I think they should be changed from this:

$this->findElement($text, "//button[contains(text(), '{$text}')]")->click();

to

$this->findElement($text, "//button[contains(., '{$text}')]")->click();

Basically the problem is with the way it is, is that text() only will find information if that is the only thing within the element. So for instance, if you have an icon within a button like:

<button class="btn btn-primary">
   <i class="fa fa-trash"></i> Delete
</button>

It will not find the text "Delete". It only finds it if it is just

<button class="btn btn-primary">
   Delete
</button>

Same thing for the click method. Change it from this:

$this->findElement($textOrId, "//a[contains(text(), '{$textOrId}')]");

to

$this->findElement($textOrId, "//a[contains(., '{$textOrId}')]");

I'm not sure there are any downsides to the change, but I'm not an xpath expert so can't be 100% sure of that. But buttons and links often have other elements within and the current implementation with text() does not seem to work with that.

@Modelizer
Copy link
Owner

Yes, agreed I think you are right and found similar question.

Thanks again 👍

@Modelizer Modelizer added the bug label Sep 19, 2016
Modelizer added a commit that referenced this issue Sep 19, 2016
Modelizer added a commit that referenced this issue Sep 19, 2016
@Modelizer
Copy link
Owner

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants