Thưa Selenium Webdriver chuyên gia,Đối sánh chuỗi() có được hỗ trợ trong Selenium Webdriver 2 không?
Tôi đang tự hỏi liệu chuỗi phù hợp với phương pháp trong Selenium Webdriver hoạt động đúng với đoạn mã sau trong Java:
if (property.findElements(By.xpath("./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house']")).size() > 0) { // line 229
Dưới đây là trang web xhtml nơi dòng 229 được đọc từ:
<dl class="cN-featDetails">
<dt class="proptype">Property type</dt>
<dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddPropertyType" class="propertytype type-house" title="Property type: House">House</dd>
Tuy nhiên, điều này dẫn đến các lỗi sau:
Address: 28B/171 Gloucester Street, Sydney
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: The given selector ./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house'] is either invalid or does not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath expression ./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house'] because of the following error:
[Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "
Tôi cũng đã thử matches(class,'propertytype.*$']")
mà không thành công.
Tên của thay đổi lớp tùy thuộc vào việc tài sản là một ngôi nhà (loại nhà) hoặc căn hộ (loại-căn hộ) ... ..
Bất kỳ gợi ý về cách sử dụng regex trong các trận đấu để kiểm tra xem có giá trị/nút cây hợp lệ trong phần tử kiểu thuộc tính này?
Đoạn mã này đang tìm kiếm this URL.
Tôi đang sử dụng Selenium 2.25.0, Java 1.7.0_11 trên Windows XP & 7 nền tảng.
Lời khuyên của bạn sẽ được đánh giá cao.