我正在尝试使用下面的标签 xpath,但我无法找到该元素。
driver.findElement(By.xpath("//div[label[contains(text(),'Patient's Name']]")).isEnabled();
XPath:
.//*[@id='update_patient_profile']/div/div[1]/label
---取自 FirePath。下面是该字段的 HTML 源代码。
<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。
最佳答案
您应该使用以下 XPATH
//*[@id='update_patient_profile']//div[2]/label[.='Patient's Name']
关于xpath - 无法使用 XPath 表达式定位 LABEL 的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18988157/