I am trying to get all href links via xpath from the following page:
href page
I tried the following:
//div[#class='article-tile__images']/a[#class='article-tile__link js-article-tile__link acte-article-catalogName-lnk']
Any suggestions what I am doing wrong?
I appreciate your replies!
Working with class attributes is much easier, readable and concise in CSS selectors:
a.article-tile__link
which matches 65 links when I issue $$('a.article-tile__link') in the Chrome console.
Related
I am using Watir 6.16 and I have come across this line of code
<div data-guid="SearchTitle" class="acme"></div>
Not sure how to locate such an element in Watir, I have tried this -
element(:search_title, custom_attribute: "SearchTitle")
But this returns nothing, so am I forced to use xpath or is there another way?
Kev
You can change that - into _, it would work. Look at the code below
browser.div(data_guid: 'SearchTitle')
I have a few hundred URLs where I'm trying to scrape the image path for an image on a page. Each page is the same format, but the div class is unique to each page.
I want to be able to use import xml in Google sheets to scrape just the content of the data-path element.
I've tried and failed to use xpath to pull out the URLs.
<div class="uniqueid active" data-path="/~/media/Images/image.jpg" data-alt="Anything"></div>
E.g. //div[#class='*']/#data-path"
Example of site: https://www.cannondale.com/en/Australia/Bike/ProductDetail?Id=77d3b8fe-41f7-42b6-bf69-b5cf0ae55548&parentid=undefined
If div class has the pattern "uniqueid active", then you can try the following XPath:
//div[contains(#class, "active")]/#data-path
Otherwise, if div class can be anything, use this query:
//div[#class]/#data-path
UPDATE:
I tried to get values of data-path attributes with IMPORTXML, but didn't succeed. Tried to do it using Python (requests and lxml) and it works. So probably the problem is in Google Sheets - some limitations or bugs, idk.
I´m working whith HTMLUnit, I need get text content of a HtmlAnchor but only text no more tags html have.
<a class="subjectPrice" href="http://www.terra.es/?ca=28_s&st=a&c=4" title="Opel Zafira Tourer 2.0 Cdti 165 Cv Excellence 5p. -12">
<span class="old_price">32.679€</span>
24.395€
If I execute htmlAnchor.getTextContent() it´s return 32.679€ 24.395€, but I only need 24.395€
Anybody can help me? thanks.
Just use XPath to get the appropriate DomText node. It seems that ./text() taking as a reference the HtmlAnchor should be enough.
Selenium Webdriver. Looking to Locate New Article from following code. Please note this is under an iframe.
<img class="rtbIcon" src="/icons/16/app/shadow/document_add.png" alt="">
<span class="rtbText">New Article</span>
I have tried to locate with xpath and many other ways. But following is what I get everytime
Code : driver.findElement(By.xpath("id('RadToolBar1'):div:div:div:ul:li[3]:a:span:span:span:span"));
Result:
The given selector id('RadToolBar1'):div:div:div:ul:li[3]:a:span:span:span:span is either invalid or does not result in a WebElement. The following error occurred:
New article has no name, id so please if some one can help find me solution.
Your xpath seems to be wrong. The best way to get the xpath for any element on a page is by installing mozilla add on - Fire Bug. You can inspect any element using this add on and also copy the correct xpath of your element present on the page.
This should be your xpath -
driver.findElement(By.xpath("//*[#class='rtbText']"));
or
driver.findElement(By.linkText("New Article"));
One of these should work. Let me know if you face any problem.
I have got following html
<a disabled="disabled"><img alt="First" src="/Content/Images/Grid/disabledFirst.png"></a>
And I run following expect on this html
expect($(element)).toBeDisabled()
where element is the selector for above html. The expect fails. Further investigation lead to following code in jasmine-jquery-1.3.1.js
toBeDisabled: function(selector){
return this.actual.is(':disabled');
},
which for some reason is returning false. I'm sure I'm missing something very basic here but just not able to spot it.
This fiddle shows that jQuery only finds inputs not anchors when using :disabled. It's understandable because the anchor element doesn't have the disabled property