> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to
> webdriver+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webdriver?hl=en.
>
>
1) In order to click on an element, it must not be hidden by CSS
(style.display != 'none' && style.visibility != 'hidden'), and it must
have width and height. This is a key difference from the Selenium 1.0
API - if the user can't interact with the element, WebDriver won't let
you either.
2) When you search for an element on the page by XPath, WebDriver
should return the first match. So this begs the question, are page 1-3
truly separate pages, or is it just one page that dynamically changes
the visibility of various forms as the user moves through the wizard?
If it's the latter, WebDriver could be picking up a "Register" button
specified earlier in the DOM, which is not visible.
3) WebDriver does not cache the results of element searches - it will
re-execute the search each time you send the command. What we do cache
is an internal ID assigned to each element found after a search. This
ID is used when you act upon the element:
// Find element and store its internal ID in a WebElement object
WebElement element =
driver.findElement(By.xpath("//button[contains(text(),'Register')]"));
// Click command sends internal ID for quick element retrieval
element.click();
// Still not searching again, just sending same internal ID
element.click();
// Search for the element again. Create and return a new ID for the result:
element = driver.findElement(By.xpath("//button[contains(text(),'Register')]"));
Since this is different from Selenium 1, which does search for the
element every time you use it, the selenium.click() command is mapped
as:
selenium.click("xpath=//button[contains(text(),'Register')]");
WebElement element =
driver.findElement(By.xpath("//button[contains(text(),'Register')]"));
element.click();
So each time your test issues a click(), WebDriver will re-search for
the element before clicking on it. This is why I brought up point (2)
- your xpath is probably picking up a different Register button on the
page than the one you expect, which is why you got the error.
I hope this helps,
Jason
//div[not(contains(@style, "display:none"))]//button[contains(text(),
'Register')]
I haven't tested this and my XPath is a bit rusty, so the above
expression may need some tweaking.
-- Jason