Session ID is null. Using WebDriver after calling quit()?

1,254 views
Skip to first unread message

hetal patel

unread,
Mar 17, 2022, 11:03:47 AM3/17/22
to qaf users
Hello,

I am facing an issue of   org.openqa.selenium.NoSuchSessionException even there is a browser open,while executing more than one tests from testng config file.
All tests execute fine, if ran individually. But when executing all tests together only first test gets executed  closing the browser at the end and then in the second test, browser opens ,but driver gives up the browser Session ID after "get" command of CommonStep while try to locate a webelement on the page.Note that bowser is still open for the test.
 I observed this behavior only when I extend "WebDriverTestCase" class in my test class.
FYI : I am not using BDD. Its all java classes and methods.
Versions: Qmetry : 3.1.0 & Selenium 4

Any help is very much appreciated.

Thank you,
Hetal

hetal patel

unread,
Mar 17, 2022, 11:21:30 AM3/17/22
to qaf users
Page Class: 
public class TestGoogle  extends WebDriverBaseTestPage<WebDriverTestPage> {

        @FindBy(locator = "test_google")
        private static QAFWebElement test_google;
       
public void getGoogle(String give) {
        get("https://www.google.ca/");
//        sendKeys(give , "test_google");
        test_google.sendKeys(give);
        Reporter.logWithScreenShot("getting screen shot..");
}
    @Override
        protected void openPage(PageLocator locator, Object... args) {
                // TODO Auto-generated method stub
       }
Test Class: 
public class RoughWork extends WebDriverTestCase {
        TestGoogle g = new TestGoogle();

      @Test
      public void googleTest2() {
       g.getGoogle("Having so much fun.."); }
         }

TestNG test:
<test name="RoughWork 2" enabled="true">
                <!-- <parameter name="action" value="new" /> -->
                <classes>
                        <class name="ca.yorku.flowable.ubix.tests.RoughWork"></class>
                </classes>
        </test>

hetal patel

unread,
Mar 17, 2022, 11:23:05 AM3/17/22
to qaf users
Forgot to mention locator:
test_google = {\"locator\":\"xpath=//input[@title='Search']\",\"desc\":\"Text to input serach\"}

I am using chrome to execute the tests.

Thank you all..

vinay u

unread,
Mar 25, 2022, 12:04:34 AM3/25/22
to qaf users
Hi All,
same happening for me as well. invalid session id if there are multiple test cases. Could you please help us on this ?
PFA , for more information.

Thanks & Regards,

Vinay
invalid_SessionID.jpg

cjayswal

unread,
Apr 6, 2022, 11:51:54 AM4/6/22
to qaf users
You don't need to close driver (driver.close). Driver close behavior can be set using "selenium.singletone" property.
If you want new session for each test you can set
selenium.singletone=method
this will set behavior to have driver session per test case.
ગુરુવાર, 24 માર્ચ, 2022ના રોજ 09:04:34 PM UTC-7 વાગ્યે vinayul...@gmail.com દ્વારા આમ લખવામાં આવ્યું હતું:

hetal patel

unread,
Apr 13, 2022, 11:43:20 AM4/13/22
to qaf users
Thank you for replaying.
I could resolve the issue of browser closer for second test by declaring the page class objects locally instead of at class level(Can't remember exact link but found a discussion on github where  Amit  mentioned  to do so). 
But I am still unable to restrict the single session of  browser  for all tests. 
selenium.singletone=  is not helping for any value when test class extends "WebDriverTestCase". I do have 7 different tests in testrun_config.xml file. for each test new browser session is created and killed after execution of that test. My requirement is to keep a browser open  from first test through 7th test. which is not happening. 
The steps can be reproduced from sample the code I have posted here. just add more tests(copy the same test) in test config xml file.
Thank you in advance.
Reply all
Reply to author
Forward
0 new messages