IntelliJ - navigate to external Url not working - throws an error

Hi Friends,

This is the first time I am posting a question to this forum. I tried to include as many details as possible here.
I am using IntelliJ IDEA for selenium automation. I am trying to automate below test cases as follows.

  1. Login to ebay.in and search JBL Speakers.
  2. From ebay.in navigate to Simplilearn website and navigate back to ebay.in

I was using the method " driver.navigate().to(“Simplilearn”) ". The first use case got executed, but second use case of navigating from ebay.in to Simplilearn failed.

The program stops executing and throws an error message - Starting ChromeDriver 81.0.4044.138 (8c6c7ba89cc9453625af54f11fd83179e23450fa-refs/branch-heads/4044@{#999}) on port 9252
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

I am using Windows 10 Home edition
Chrome browser Version 81.0.4044.138 (Official Build) (64-bit) and chrome driver 81.0.4044 IntelliJ IDEA 2020.1.1 community edition.

Below is the program I am trying to execute:

package com.Selenium_ICT_intellij;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ebaySearch {
WebDriver driver;

public void launchBrowser(){
    System.setProperty("webdriver.chrome.driver", "C:Path to chromedriver.exe");
    driver = new ChromeDriver();
    driver.get("https://www.ebay.co.uk/");
}

public void searchProduct() throws InterruptedException {
    Thread.sleep(2000);
    driver.findElement(By.id("gh-ac")).sendKeys("JBL Speakers");
    driver.findElement(By.id("gh-btn")).click();
    Thread.sleep(2000);
    driver.findElement(By.linkText("Deals")).click();
}

public void navigateUrl() throws InterruptedException {
    Thread.sleep(2000);
    driver.navigate().to("https://www.udemy.com/");
    Thread.sleep(3000);

}
public static void main (String args[]) throws InterruptedException {
    ebaySearch obj = new ebaySearch();
    obj.launchBrowser();
    obj.searchProduct();
    obj.navigateUrl();
}

}

Screenshot of Error message:

In all honesty this doesn’t seem as an error. I know it is red, but that is IntelliJ not adhering to normal colour schemes.

And the message should be informational message only. What the message is telling you is that the chromedriver only accepts connections from the local machine. So you cannot give chromdriver commands from outside.

2 Likes

Maybe it’s better to forward it to https://intellij-support.jetbrains.com/

1 Like

Hi @ravishankarste , trying to reproduce the issue i see that element locator for “Deals” -> driver.findElement(By.linkText(“Deals”)).click();
report the error:
Exception in thread “main” org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“link text”,“selector”:“Deals”}

Maybe try to locate the element with other locator method helps.

1 Like

Thank you Zejnilovic.

Thank you Milan… I think that is the problem and so the code after that also does not work. It stops there and quits.