I am looking for some help as am just getting into a web automation using Selenium with the Java bindings. I am trying to find the total number of text boxes on a web page, I have the code working for checking @type=text
. The code is below, however, when I try to find text boxes by:"//input[@type='text'[@class='dijitReset dijitInputInner']"
and it fails. The full code is below.
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch browser
driver.get("http://localhost/2010A15/?p=register");
//Create Web element list
java.util.List<WebElement> textboxes = driver.findElements(By.xpath("dijitReset dijitInputInner']"));
System.out.println(textboxes.size());
for(int i=1; i<=textboxes.size(); i=i+1);
{
System.out.println(textboxes.size());
}
driver.close();
}
}
Error Message:
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: The given selector dijitReset dijitInputInner'] is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Unable to locate an element with the xpath expression dijitReset dijitInputInner'] because of the following error: SyntaxError: The expression is not a legal expression.
I presume the error is telling me that dijitReset dijitInputInner
is not valid and that's why it isn't working, however, I am unsure on how to fix this. Any help? As the class of the item in inspect element is: dijitReset dijitInputInner
.
3条答案
按热度按时间crcmnpdw1#
如果你只想计算元素(文本框)的数量,那么你可以通过使用size()来避免循环每个webelement
kb5ga3dv2#
dgenwo3n3#