[英]how to get a class value from text box Webdriver using Java
test condition - to verify the field validation ,ie if i enter a invalid data in that Text box, then capture the Exception value and verify the same (Please enter first name) so, following are my HTML code 测试条件-验证字段验证,即,如果我在该文本框中输入了无效数据,然后捕获Exception值并进行验证(请输入名字),那么以下是我的HTML代码
Before Execution (validation) 执行前(验证)
<input type="text" class="input-txt" data-bind="value: FirstName" id="txtFirstName"
title="Please enter first name" data-orig-title="">
<span class="f-req" style="display: none;"></span>
After Execution of Validation 执行验证后
<input type="text" class="input-txt ErrorControl" data-bind="value:
FirstName"id="txtFirstName" title="Please enter first name" data-orig-title="">
<span class="f-req" style="">Please enter first name</span>
how can verify the validation message if exist or not during invalid entry pass in that object 在该对象的无效输入过程中,如何验证验证消息是否存在
my code is 我的代码是
\\ passing empty value so its thrown an error message
firstname.sendKeys("");
\\checking if the "input-txt ErrorControl" class are enabled or not
System.out.println("class name" + firstname.getAttribute("class"));
if i execute it always getting "input-txt" class not getting the "input-txt ErrorControl" 如果我执行它总是得到“ input-txt”类而不得到“ input-txt ErrorControl”
Please provide help how to handle this 请提供有关如何处理此问题的帮助
Thanks 谢谢
prabu 普拉布
try to sendKeys(" ")
of another invalid symbols. 尝试发送另一个无效符号的
sendKeys(" ")
。 And then use this check: 然后使用此检查:
webdriver.findElement(By.cssSelector("input#txtFirstName")).getAttribute("class").contains("ErrorControl")
String Validationmessage = driver.findElement(
> By.cssSelector("input#txtFirstName")).getAttribute("title");
for the above i will got the validation message for that particular Field 对于上述,我将获得该特定字段的验证消息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.