1

I tried to implement the solution provided here:

Java how to manipulate a html text element with dynamic generated name?

It worked but when I did inspect element the HTML was as is, no change was made to the page. It didn't give any error.

This is what I tried:

        gotoPage("https://www.demo.com/in/");
        Document doc = Jsoup.connect("https://www.demo.com/in/").get();
        System.out.println("Before "+doc.select("#top-menu > div > div.nav-logo > a").first());
        Element e = doc.select("#top-menu > div > div.nav-logo > a").first();
        e.attr("href", "https://demo-custom-page.net/demo/test-jsoup.html");
        System.out.println("After "+doc.select("#top-menu > div > div.nav-logo > a").first());
        Thread.sleep(120000);   // inspect element and if html changed or not 

I am working on Windows 7, Java, Selenium, Maven

paul
  • 4,333
  • 16
  • 71
  • 144

2 Answers2

0

You can't. When you edit HTML using Jsoup the only thing modified is the document you store in doc variable. You won't see these changes in web browser.

Krystian G
  • 2,842
  • 3
  • 11
  • 25
0

Maybe you can do that if you create threads for "atomic" things. Some solution is to use File and FileUtils.writeStringToFile() to write in file.

Mihai8
  • 3,113
  • 1
  • 21
  • 31