T
T
TechNOIR2017-09-20 12:42:13
css
TechNOIR, 2017-09-20 12:42:13

Selenium+Xpath. How to get a chain of categories?

Good day.
By this link
I want to get a list of categories (breadcrumbs) "Main Catalog Car tools BMW tools"
separated by commas or spaces.
I'm trying with a simple script:

[Reflection.Assembly]::LoadFrom("C:\selenium\net40\WebDriver.dll")
$ie = New-Object OpenQA.Selenium.Firefox.FirefoxDriver
$ie.Navigate().GoToUrl("http://car-tool.ru/catalog/bmw-tools/fiksator_kolenvala_bmw_b38/")
Start-Sleep 5
$ie.FindElementByXPath("//ul[@class='breadcrumb-navigation']/li/a")
$ie.Quit()

If I use $ie.FindElementByXPath("//ul[@class='breadcrumb-navigation']/li/a") then I get only the first element "Home".
If I use $ie.FindElementByXPath("//ul[@class='breadcrumb-navigation']") then the elements are all in a heap.
How can I get either all separately or separated by commas?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Usachov, 2019-06-06
@coderart

A
Anatoly Kulikov, 2019-06-05
@anatoly_kulikov

In js, write a function that, depending on the number of incoming files, builds the desired grid (with the required number of elements), and then everything is formatted through CSS and that's it. Or a similar option - js looks at the number of objects and adds a modifier class to the parent container.

R
Roman Fov, 2017-09-20
@TechNOIR

Xpath
True.
I am not familiar with selenium and povershely, but I dare to suggest that the problem may be here
. Based on the name, I think it should grab only one element.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question