Using XPATH to search text containing  

It seems that OpenQA, guys behind Selenium, have already addressed this problem. They defined some variables to explicitely match whitespaces. In my case, I need to use an XPATH similar to //td[text()=”${nbsp}”]. I reproduced here the text from OpenQA concerning this issue (found here): HTML automatically normalizes whitespace within elements, ignoring leading/trailing spaces and converting … Read more

Get nodes where child node contains an attribute

Try //book[title/@lang = ‘it’] This reads: get all book elements that have at least one title which has an attribute lang with a value of “it” You may find this helpful — it’s an article entitled “XPath in Five Paragraphs” by Ronald Bourret. But in all honesty, //book[title[@lang=’it’]] and the above should be equivalent, unless … Read more

How can I convert a string to upper- or lower-case with XSLT?

In XSLT 1.0 the upper-case() and lower-case() functions are not available. If you’re using a 1.0 stylesheet the common method of case conversion is translate(): <xsl:variable name=”lowercase” select=”‘abcdefghijklmnopqrstuvwxyz'” /> <xsl:variable name=”uppercase” select=”‘ABCDEFGHIJKLMNOPQRSTUVWXYZ'” /> <xsl:template match=”https://stackoverflow.com/”> <xsl:value-of select=”translate(doc, $lowercase, $uppercase)” /> </xsl:template>

How to use XPath in Python?

libxml2 has a number of advantages: Compliance to the spec Active development and a community participation Speed. This is really a python wrapper around a C implementation. Ubiquity. The libxml2 library is pervasive and thus well tested. Downsides include: Compliance to the spec. It’s strict. Things like default namespace handling are easier in other libraries. … Read more

Select parent element of known element in Selenium

There are a couple of options there. The sample code is in Java, but a port to other languages should be straightforward. Java: WebElement myElement = driver.findElement(By.id(“myDiv”)); WebElement parent = (WebElement) ((JavascriptExecutor) driver).executeScript( “return arguments[0].parentNode;”, myElement); XPath: WebElement myElement = driver.findElement(By.id(“myDiv”)); WebElement parent = myElement.findElement(By.xpath(“./..”)); Obtaining the driver from the WebElement Note: As you can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)