以下是示例硒代碼。什麼將是這種有效XPATH或更好的正則表達式可以用來建議爲以下代碼提供便宜的XPATH
@FindBy(xpath = ".//*[@id='Insurance_number' or @id='id_insurance_number_text' or @id = 'sInsuranceNumber']")
以下是示例硒代碼。什麼將是這種有效XPATH或更好的正則表達式可以用來建議爲以下代碼提供便宜的XPATH
@FindBy(xpath = ".//*[@id='Insurance_number' or @id='id_insurance_number_text' or @id = 'sInsuranceNumber']")
你可以嘗試以下的變體:
@FindBy(xpath = ".//*[@id != ''][contains('Insurance_number;id_insurance_number_text;sInsuranceNumber', @id)]")
更簡潔,但我不知道這是否產生更好的性能。
替換爲您的XPath」 .//*[ends-with(@id,'nsurance')]」
它假定它爲你工作。
它不會,因爲xpath是區分大小寫的 - 它不會捕獲id_insurance_number_text。 – ljedrz
同意ljedrz – TestGeeK
ok..try「.//*[ends-with(@id,'nsurance')]"..updated我的回答 – RamaKrishna
selenium不支持正則表達式,因爲它支持'xpath 1.0',爲了更好的'xpath'解決方案你能不能共享HTML? –
將針對每個選定的產品更改html。 – TestGeeK