![](/img/trans.png)
[英]How to provide loop for char A to Z which is passed in XPath after that may be we don't need to write XPath for multiple times
[英]How to write xpath which have multiple values (two lines) in label
我試過這個,
//label[text()='Legal Business Nam(開戶后可以添加DBA)']
//label[text()='Legal Business Name' and '(開戶后可以添加DBA)']
但不起作用。
<div class="form-group col-md-12"><label>Legal Business Name (you can add a DBA after your account is open )</label><input type="text" class="form-control required" placeholder="Enter legal business name" name="company_name" maxlength="250" value=""><label id="company_name-error" class="help-block text-danger validation-error" for="company_name"></label></div>
您可以嘗試使用.
而不是text()
。
//label[contains(., 'Legal Business Name (you can add a DBA after your account is open )')]
或者像這樣加入 2 個[contains(text(), '')]
語句:
//label[contains(text(), 'Legal Business Name ')][contains(text(), '(you can add a DBA after your account is open )')]
看來你已經夠近了。 您需要使用contains()
而不是text()
) ,如下所示:
//label[contains(., 'you can add a DBA after your account is open')]
理想情況下,您必須為visibilityOfElementLocated()
引入WebDriverWait ,並且可以使用以下基於xpath的定位器策略:
new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(., 'you can add a DBA after your account is open')]")))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.