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

CAnnot SElect an option from a list using Xpath #250

Closed
beedge72 opened this issue Apr 5, 2013 · 8 comments

Comments

Projects
None yet
4 participants
@beedge72
Copy link

commented Apr 5, 2013

I am trying to select the first item from a dynamic list using web guy.

I have tried every variation of X Path I can think of, but I always get the same result.

WebDriver\Exception\InvalidSelector: The given selector //html/form select[name=type]/*[1] is either invalid or does not result in a WebElement.

can someone tell me if the above Xpath for the first option of a select list named type is correct?

@Ragazzo

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2013

there are some answers on your twitter about css, did u checked them? are they not working for you? I mean select:first-child or :has or :contains? or u need exactly xpath and not css?

@beedge72

This comment has been minimized.

Copy link
Author

commented Apr 5, 2013

Thats strange, I dont see anything on my Twitter. Anyway, tried this:

$value = $I->grabTextFrom('form select[name=aid]:first-child');

and I end up with the same error.
I cant use :contains or :has as the list elements are dynamic and loaded via ajax, so the whole point of it is that I dont know what the list will contain.

@beedge72

This comment has been minimized.

Copy link
Author

commented Apr 5, 2013

Finally got it with this: $value = $I->grabTextFrom('//*[@id="edit-aid"]/option[1]');

@Ragazzo

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2013

Name attribute must be in quotes like name="aid"
upd. oh, you already got the solution, well ok)

@beedge72

This comment has been minimized.

Copy link
Author

commented Apr 5, 2013

Ah, right, thats where I was going wrong then. Thanks

@Ragazzo

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2013

You also can close issue if it is ok now ;)

@DavertMik

This comment has been minimized.

Copy link
Member

commented Apr 5, 2013

Yep, CSS is pretty limited here, so I recommended you to use XPath in Twitter :)
Nice to see that you found the right locator.

@DavertMik DavertMik closed this Apr 5, 2013

@clouddueling

This comment has been minimized.

Copy link

commented Jul 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.