[英]How to Enter Text in Contact form using selenium Webdriver?
public static void main(String[] args)
{
WebDriver wd = new FirefoxDriver();
wd.manage().window().maximize();
wd.get("http://www.arthritisspecialityclinic.com");
WebElement link=wd.findElement(By.linkText("CONTACTS"));
link.click();
WebElement Name = wd.findElement(By.xpath(".//*[@id='contact-form']/fieldset/label[1]/span[3]"));
Name.sendKeys("sakthivel");
}
I've executed the above code for Enter text in NAME text box under contact Form in website..But the text is not typed in the specific field only shown Blank...No error also shown in web driver...Any one can help me to Fix this.... 我已经执行了上面的代码,用于在网站的联系表单下的“名称”文本框中输入文本。但是,该文本未在特定字段中键入,仅显示为空白... Web驱动程序中也未显示错误...任何人都可以帮我解决这个问题。
Your xPath is wrong. 您的xPath错误。 You should select the
input
tag instead of the span
tag. 您应该选择
input
标签而不是span
标签。 Try this: 尝试这个:
WebElement name = wd.findElement(By.xpath("//form[@id='contact-form']/fieldset/label[1]/input"));
name.sendKeys("sakthivel");
Suggestion: This would be a cleaner method to select the WebElement
. 建议:这是选择
WebElement
的更干净的方法。
WebElement name = wd.findElement(By.xpath("//input[@name='name']"));
name.sendKeys("sakthivel");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.