0

The below steps will give you a better idea, what i am exactly trying to achieve.

  1. Open a URL, for example https://www.google.com in Chrome Browser.

  2. After the page has opened, i want to click on the bookmark namely "ABC", which has the URL ({window.open('/output_debug_info.jsp');})();) -- I HAVE ALREADY CREATED THIS BOOKMARK.

  3. I want to Click on the "ABC" Bookmark, and it should open a new page in the new tab of chrome containing the information of the URL https://www.google.com.

  4. In the new tab, i want to fetch few information like name, address etc and print those in my Selenium Console.

Please help me, how i can achieve the following steps....

Thanks

  • I don't think selenium can do it. It will be a problem if the website can read what have you bookmarked before. I guess your bookmark is a js script. How about just run it directly? – Kit Fung May 30 '16 at 07:41
  • @KitFung thanks for your suggestion! ok if we are unable to click on the bookmark directly through selenium, then can we run that script ({window.open('/output_debug_info.jsp');})();), directly on that page? my purpose was just to run this script on the current open page so that i can fetch informations like name, address etc and print those in my Selenium Console. – Ghulam Mohammad May 30 '16 at 08:39

1 Answers1

2

To run Java script using Selenium, check out below code -

    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("alert('Hello')");

Replace "alert('Hello')" with your java script.