Facing Error when opening Firefox again

Hi WF Team,

I have used two browser, Chrome and Firefox, both are opened one by one, but Firefox browser closes automatically. I have tried to reopen Firefox but faced below error.

org.openqa.selenium.SessionNotCreatedException: Tried to run command without establishing a connection
Build info: version: '9.1.0.0', revision: 'fd814778f3', time: '2018-08-23T11:59:12.788Z'
System info: host: 'LICWBVXCKF', ip: '16.168.205.196', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{moz:profile=C:\Users\kushwah\AppData\Local\Temp\rust_mozprofile.TnCsGojSxsHR, rotatable=false, capabilities={desiredCapabilities={browserName=firefox}}, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, moz:headless=false, platform=XP, moz:accessibilityChecks=false, moz:useNonSpecCompliantPointerOrigin=false, acceptInsecureCerts=false, browserVersion=66.0.2, moz:shutdownTimeout=60000, platformVersion=10.0, moz:processID=9292, browserName=firefox, javascriptEnabled=true, platformName=XP, setWindowRect=true, moz:webdriverClick=true}]
Session ID: 0a0daad2-85e5-4fd2-9eca-c18d22d2f53d
Command duration or timeout: 0 milliseconds

Hi @shiv_kushwah.
Could you please clarify how you reopened Firefox? You can share part of your script when you opened your browsers.
By the way, why do you need to open 2 browsers?

Please find my sample code, it is require my current project.

<?xml version="1.0" encoding="UTF-8"?>
<robotics-flow>
	<robot driver="universal" close-on-completion="true"
		start-in-private="false">
		<capability name="SEARCH_ALL_WINDOWS" value="true" />
		<capability name="CLOSE_ALL_WINDOWS" value="false" />
		<script><![CDATA[
			import com.workfusion.studio.rpa.recorder.api.*
			import com.workfusion.studio.rpa.recorder.api.types.*
			import com.workfusion.studio.rpa.recorder.api.custom.*
			import com.workfusion.studio.rpa.recorder.api.internal.representation.*

			import com.workfusion.bot.exception.*


			com.workfusion.rpa.helpers.RPA.metaClass.static.$ = { Closure c -> c.call() } // Support for Expression action. Should be implemented in RPA class in next release.

			enableTypeOnScreen()

			/* Open google.co.in in Chrome  
			 */

			inChrome(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openChrome(UrlOperations.ensureProtocol("https://www.google.co.in/"))
				window().maximize()
				sleep(3000)
			}

			inFirefox(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openFirefox(UrlOperations.ensureProtocol("https://www.google.co.in/"))
				window().maximize()
				sleep(3000)
				sleep(2000)
				close() // Some time Closed automatically
			}

			sleep(3000)
			inFirefox(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				window().maximize()
				openFirefox(UrlOperations.ensureProtocol("https://www.google.co.in/"))
				window().maximize()
			}
		]]></script>
	</robot>
</robotics-flow>
<export include-original-data="true">
</export>

Thank you. I was able to reproduce the issue on my side. Let me clarify why it happens.

I discussed internally and it looks like you don’t need to use close() method in your script. It works for me without this method. New link will be opened in the existed browser window instead of previous link.

inChrome(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openChrome(UrlOperations.ensureProtocol("https://www.google.co.in/"))
				window().maximize()
				sleep(3000)				
			}

			inFirefox(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openFirefox(UrlOperations.ensureProtocol("https://www.google.co.in/"))
				window().maximize()
				sleep(3000)				
			}
		    
		    sleep(5000)
		 
			inFirefox(){
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openFirefox(UrlOperations.ensureProtocol("https://www.amazon.com"))
				window().maximize()
			}
1 Like