Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to close and open browser

View previous topic View next topic Go down

How to close and open browser

Post by ashv on Sat Feb 07, 2015 9:06 pm

Hi,

Once I execute selenium code/functionality, I want to close browser.
Therefore, I used "driver.close();" and its closed the browser window. (I am using chrome webdriver.)

However, I want to reopen my browser for next functional code execution. This code executes:
driver.get("website link");
But I am getting exception, "VisitURL failed because of: no such session".

Looks like "driver.close" is closing the driver too and I need to reinitialize webdriver something like "WebDriver driver = new ChromeDriver();".
Now, I do not want to call this webdriver initialization. My motive is just to close browser and reopen it.
Please suggest.

Thanks,
Ashvini

ashv

Posts : 2
Join date : 2015-02-07
Location : India

Back to top Go down

Re: How to close and open browser

Post by ccox on Fri Feb 13, 2015 12:26 am

I believe that parent window is attached to the driver session.  Why do you want to close it and reopen it? What does that save you? If you are using a testing framework, you would typically create a new webdriver instance for each test. There are specific tags you can use depending on your language, such as @SetUp for C#, which will run a method at the beginning of each test.  Closing the browser and maintaining the same session seems to over complicate the test while gaining no benefit

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: How to close and open browser

Post by AgoBalan on Mon Feb 23, 2015 3:43 pm

closing the driver or closing the browser boith are same.... close it wen all your testcases completed.. else invoke new browser before each test case..

AgoBalan
Amateur
Amateur

Posts : 36
Join date : 2015-02-23

Back to top Go down

Re: How to close and open browser

Post by l3l00 on Wed Feb 25, 2015 9:53 pm

AgoBalan is right, at the end it should close browser because of your Teardown.

I personally add quits & close in some parts of some testcases in the event that the testcase really cannot continue if a specific area cannot be executed properly. Such as like a submit button.

Taken off Seleniums Docs there are two methods you can call to close the browser:

close()
Close the current window, quitting the browser if it's the last window currently open.

quit()
Quits this driver, closing every associated window.

l3l00
Active particpant
Active particpant

Posts : 11
Join date : 2015-01-06

Back to top Go down

Re: How to close and open browser

Post by Sponsored content Today at 3:52 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum