Note that there are some explanatory texts on larger screens.

plurals
  1. POIs string matches() supported in Selenium Webdriver 2?
    primarykey
    data
    text
    <p>Dear Selenium Webdriver Experts,</p> <p>I am wondering whether the string matches method in Selenium Webdriver is working properly with the following code snippet in Java:</p> <pre><code>if (property.findElements(By.xpath("./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house']")).size() &gt; 0 ) { // line 229 </code></pre> <p>Below is the xhtml webpage where line 229 is reading from:</p> <pre><code>&lt;dl class="cN-featDetails"&gt; &lt;dt class="proptype"&gt;Property type&lt;/dt&gt; &lt;dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddPropertyType" class="propertytype type-house" title="Property type: House"&gt;House&lt;/dd&gt; </code></pre> <p>However, this resulted in the following error:</p> <pre><code>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: " </code></pre> <p>I have also tried <code>matches(class,'propertytype.*$']")</code> without success either.</p> <p>The name of class changes depending on whether the property is a house (type-house) or apartment (type-apartment)…..</p> <p>Any suggestion on how to use regex in matches to check whether there is value / valid tree node in this property type element?</p> <p>This code snippet is looking up <a href="http://www.domain.com.au/Search/buy/?nosurl=1&amp;mode=buy&amp;&amp;state=NSW&amp;regions=Sydney+Region&amp;areas=Sydney+City&amp;sub=Dawes+Point%2cHaymarket%2cMillers+Point%2cSydney%2cThe+Rocks%2cCircular+Quay%2cCockle+Bay%2cWalsh+Bay%2cDarling+Harbour&amp;ptypes=119,220,213,198,210,76,172,113&amp;ptdes=House%2c+Villa%2c+Townhouse%2c+Semi-Detached%2c+Terrace%2c+Duplex%2c+Penthouse%2c+New+Home+Designs&amp;from=350000&amp;searchterm=2000" rel="noreferrer">this URL</a>.</p> <p>I am using Selenium 2.25.0, Java 1.7.0_11 on Windows XP &amp; 7 platforms.</p> <p>Your advice would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload