无法使用XPath表达式定位LABEL的元素 [英] Unable to locate element for LABEL with the XPath expression
本文介绍了无法使用XPath表达式定位LABEL的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试下面的Label的xpath,但无法找到该元素.
I am trying the below xpath for Label, but I'm not able to locate the element.
driver.findElement(By.xpath("//div[label[contains(text(),'Patient's Name']]")).isEnabled();
XPath:.//*[@id='update_patient_profile']/div/div[1]/label
---来自FirePath.
XPath: .//*[@id='update_patient_profile']/div/div[1]/label
---Taken from FirePath.
下面是该字段的HTML源.
Below is the HTML source for the field.
<form id="update_patient_profile" action="/subscriber/" method="post" name="update_patient_profile">
<div class="subscriberAddPatient">
<div class="formData nameInputs">
<label for="first_name">Patient's Name</label>
<input id="first_name" class="left nameRule" type="text" onblur="resetTxtAdd($(this))" onfocus="emptyFieldAdd($(this))" onclick="emptyFieldAdd($(this))" name="first_name" value="First Name" maxlength="24"/>
任何人都可以为我建议标签的正确XPath.
Can anyone suggest me the correct XPath for the Label.
推荐答案
您应使用下面的 XPATH
//*[@id='update_patient_profile']//div[2]/label[.='Patient's Name']
这篇关于无法使用XPath表达式定位LABEL的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文