inputText1= browserFactory.getDriver().findElement(By.xpath("//table[@class='table-table-bordered']//tbody/tr));
WebElement childAttr = inputText1.findElement(By.xpath("./child::"));
if (childAttr.getTagName()=="input") // if the type of the field is input textbox,,then below will happen
{
inputText1.findElement(By.xpath("./input"));
SendKeys(inputText1,"TypeInput");
}
else if (childAttr.getTagName()=="./select")); // if its is dropdown
{
inputText1.findElement(By.xpath("./select"));
SelectListValueName(inputText1,"TypeSelect");
}
在“child::”处抛出异常不是正确的字符串。删除“./”并尝试。这是正确的方法吗
为什么你不能简单的使用getTagName()方法来获取元素标签。
row= browserFactory.getDriver().findElement(By.xpath("//table[@class='table-table-bordered']//tbody/tr]"));
WebElement targetEle = inputText1.findElement(By.xpath(".//*[local-name()='input' or local-name()='select']");
// check if the row have either input/listbox
if (targetEle.getTagName().equals('input')) // if the type of the field is input textbox,,then below will happen
{
SendKeys(targetEle,"TypeInput");
}
else if (targetEle.getTagName().equals("select")); // if its is dropdown
{
SelectListValueName(targetEle,"TypeSelect");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句