Cannot Connect to LocalHost - Chrome


#1

Hey Everyone,

I am having an issue in which I am running some automation in which I am able to connect/log into to the site, but when i try to click a link I am getting the following error message:

Test Cases/Test Test FAILED.
Reason:
com.thoughtworks.selenium.SeleniumException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:27202
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: '2018-11-14T08:25:53’
System info: os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: '1.8.0_181’

I did just update my machine from Windows 7 to Windows 10 and my Chrome Browser was updated to version 78 in the process. I did download the most recent chrome driver for v78 and replaced the file in Katalon. (https://chromedriver.storage.googleapis.com/index.html?path=78.0.3904.105/)

My code is as follows. I am using a custom keyword to log into the site, but that step is completing successfully.

String baseUrl = 'http://site:7932/'

//Set chrome driver to the local executable
System.setProperty('webdriver.chrome.driver', 'C:\\Users\\TDube\\Desktop\\Katalon_Studio_Windows_64-6.2.1\\configuration\\resources\\drivers\\chromedriver_win32\\chromedriver.exe')

ChromeOptions driverOptions = new ChromeOptions()
driverOptions.setExperimentalOption('useAutomationExtension', false)
WebDriver driver = new ChromeDriver(driverOptions)
DriverFactory.changeWebDriver(driver)
selenium = new WebDriverBackedSelenium(driver, baseUrl)

//Log in
WebUI.executeJavaScript('function myFunction() { setTimeout(function(){ window.location.href = \'http://site:7932\'; }, 500);}; myFunction()', [])
CustomKeywords.'auth_keyword.loginAuthenticate'(GlobalVariable.username, GlobalVariable.password)

//Navigate to the accounts page 
selenium.click('id=Accounts')
WBS.verifyTrue(selenium.isElementPresent('link=Add New Account'))

Thanks in advance for the help!


#3

Curious, was this just running a test or were you running a few in parallel ? Ive seen this issue before when the ports are being exhausted on the host machine.


#4

i think the error is generated when attempting to spawn the local proxy for chromedriver … by chance during that execution tried to start on an already occupied port?
other explanation can be a paranoid local firewall… or messing with the host file.
@TDube if you try it again, does the 27202 change or is allways the same?


#5

Hey guys.

Currently I am running only this one test. I just tried running it again and I am getting a different port this time.

Test Cases/Account Rule Page Test FAILED.
Reason:
com.thoughtworks.selenium.SeleniumException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:15956

Also in regards to the base URL. I edited only the site name before i submitted my code, I left the port alone.


#6

@kazurayam @hpulsford @Russ_Thomas @ThanhTo looks for me like chromedriver ‘proxy’ is blocked. anyone hit by this before?

@TDube do you have any firewall installed on your machine?


#7

I do have windows firewall on my machine for private and public networks