1

My Application has a Functionality which takes time to load the search results like more then a minute because of which my scripts fails and gives a 60 seconds session timeout error message. I googled few solutions and got one from stack overflow"How to set session timeout in web.config" but i am not sure where exactly to implement it. i have a file in my framework called "app.config" and the code in the app.config is below

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This Below mentioned code is given in the stack overflow to make necessary changes in web.config file to set the session timeout

<configuration>
  <system.web>
     <sessionState timeout="20"></sessionState>
  </system.web>
</configuration>

please help me where to make the necessary changes in app.config file.

Hargovind
  • 73
  • 11
  • 1
    The `timeout` setting in the web.config is for the web application. For Selenium, you would need to set it in your code. This is the official documentation: https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp `WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));` More specifically, where are you getting time out ? If you add your code / exception stack trace, you are likely to get better / more appropriate solutions. – Subbu Aug 22 '18 at 17:26

1 Answers1

1

You could set an implicit wait for the driver in the following fashion:

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.

Now the only reason to use app.config is if you want to make this timeout configurable. In which case in your app.config file you would add a section:

<appSettings>
    <add key="driver.Timeout" value="20" />
</appSettings>

Then in your code you would do something like:

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(Int32.Parse(ConfigurationManager.AppSettings["driver.Timeout"]));

This way if you deploy your app somewhere and wanted to make the timeout configurable you would just edit your app.config file in a text editor and change the value.

so cal cheesehead
  • 2,515
  • 4
  • 29
  • 50