Drodzy selen Webdriver ekspertów,Czy łańcuch znaków jest zgodny() w Selenium Webdriver 2?
Zastanawiam się, czy ciąg pasuje do sposobu w selen Webdriver działa prawidłowo z poniższym fragmencie kodu w Javie:
if (property.findElements(By.xpath("./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house']")).size() > 0) { // line 229
Poniżej znajduje się strona xhtml gdzie linia 229 czyta od:
<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>
jednakże skutkowało to w następujący błąd:
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: "
Próbowałem również matches(class,'propertytype.*$']")
bez powodzenia.
Nazwa zmiany klasy w zależności od tego, czy nieruchomość jest dom (typ-house) lub mieszkanie (typu apartament) ... ..
Wszelkie sugestie, w jaki sposób użyć wyrażenia regularnego w meczach, by sprawdzić, czy istnieje wartość/poprawny węzeł drzewa w tym elemencie typu właściwości?
Ten fragment kodu jest wyświetlany w górę this URL.
Używam Selenium 2.25.0, Java 1.7.0_11 na Windows XP & 7 platform.
Twoja rada byłaby mile widziana.
- Typ nieruchomości
- House –