Open GoogleCodeExporter opened 8 years ago
The description error is "no such element" which mean that the HTML node
doesn't exist in the page.
If you look at the page source, you'll see that the data you are trying to
extract is some JSON text, which is not handled by Selenium.
Selenium may not be the right tool here as there is no interaction to perform
with the browser.
A better and faster way would be to use the WinHttpRequest object to download
the page and the ScriptControl to parse the JSON data.
Anyway, this is how it can be done with Selenium using some JavaScript to parse
the JSON text:
Dim driver As New SeleniumWrapper.WebDriver
driver.HideCommandPromptWindow = True
driver.Start "chrome", "http://maps.googleapis.com/maps/api/distancematrix"
driver.Open
"/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=
bicycling&language=fr-FR&sensor=false"
distances = driver.executeScript("var
rows=eval('('+document.getElementsByTagName('pre')[0].textContent+')'
)['rows']; return [ rows[0]['elements'][0]['distance']['value'],
rows[0]['elements'][1]['distance']['value'],
rows[1]['elements'][0]['distance']['value'],
rows[1]['elements'][1]['distance']['value']]")
The content of "distances" is an array with the 4 distances.
Original comment by florentbr
on 22 Apr 2014 at 3:14
Thank you for your help! It's work!
Original comment by olena.kr...@gmail.com
on 23 Apr 2014 at 11:44
Original comment by florentbr
on 8 Sep 2014 at 5:40
Original issue reported on code.google.com by
olena.kr...@gmail.com
on 21 Apr 2014 at 12:22