0

I'm trying to automate my routine job. I could see the web shows a lot of elements when inspect a element, but when I click view page source I see only Gibberish words. I want to extract the page element can someone help me. My page sample is below;

Note: there is a svg and g tag in the following page

View page source details :

<body><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="75px" height="75px" viewbox="0 0 75 75" preserveaspectratio="none" class="startLoaderImg" style="position:absolute;top:0;left:0;right:0;bottom:0;margin:auto"><g><image width="75" height="75" xlink:href="data:image/gif;base64,
R0lGODlhSwBLAKUAAIyOjMTKzKyurOTm5JyenLy+vNza3PT29JSWlMzS1LS2tKSmpOzu7MTGxJSS
........  "></image></g><image style="position:absolute;top:0;left:0;right:0;bottom:0;margin:auto" class="startLoaderImg" id="startLoaderImg"></svg></body>

My HtmlUnit java code couldnt find the target element. Can anyone please help me?

Dilli
  • 13
  • 6

1 Answers1

0

You have to use xpath to fetch value of appropriate tag.

eg:

/body/g

Also you have to learn about the tool for automation eg Selenium Web Driver

WebDriver driver = new FirefoxDriver();
WebElement userName =
driver.findElement(By.xpath("html/body/div/form/input"));
Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192
  • Rudziankou thanks for your answer. I'm using HtmlUnit, When I try to get an element by its Xpath, I'm getting following error java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.gargoylesoftware.htmlunit.html.HtmlElement – Dilli Jul 19 '16 at 11:51