I am using selenium webdriver with java & i am unable to locate a perticular button from total of 6 similar elements present on the page.I tried using XPath with 'value' attribute as:- //input[@value = 'New PAN for Indian Citizens (Form 49A)'] but was unable to find the element. HTML for all the 6 buttons are as follows:-
<input type="submit" onclick="javascript:popitup('0','',false);" style="{width:22em}" value=" New PAN for Indian Citizens (Form 49A) " name="submit">
<input type="submit" onclick="javascript:popitup('5','',false);" style="{width:22em}" value=" New PAN for Foreign Citizens (Form 49AA) " name="submit">
<input type="submit" onclick="javascript:popitup('1','',false);" style="{width:22em}" value="Changes or Correction in PAN details" name="submit">
<input type="submit" onclick="javascript:popitup('1','',false);" style="{width:22em}" value=" Reprint of PAN card " name="submit">
<input type="submit" onclick="javascript:popitup('2','',false);" style="{width:22em}" value=" Transaction Status Enquiry " name="submit">
<input type="submit" onclick="javascript:popitup('3','',false);" style="{width:22em}" value=" Status Track for PAN application " name="submit">
Please help me folks. . . thanks in advance
you should mention attribute values in the same way as mentioned in HTML,so even the space matters...
driver.findElement(By.xpath("//input[@value=' New PAN for Indian Citizens (Form 49A) ']"));
or
driver.findElement(By.cssSelector("input[value=' New PAN for Indian Citizens (Form 49A) ']"));
或者,您可以尝试部分匹配:
driver.findElement(By.xpath("//input[contains(value, '(Form 49A)')]"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.