예제 #1
0
        private ChromeSession AddSession(ChromeSessionInfo info)
        {
            var session = new ChromeSession(info, this);

            _aliveSessions.Add(session.Id, session);
            return(session);
        }
예제 #2
0
        /// <summary>
        /// Closes the provided Session(Tab)
        /// </summary>
        /// <param name="session">Session to be closed</param>
        /// <returns></returns>
        public async Task CloseSession(ChromeSession session)
        {
            //TODO:if i close all the sessions, chrome closes itself! i can use this to gracefully close this stuff, OR maybe i should prevent it?
            using (var webClient = GetDebuggerClient())
            {
                var result = await webClient.PostAsync("/json/close/" + session.Id, null);

                var contents = await result.Content.ReadAsStringAsync();

                //Assert contents == "Target is closing"
                if (_aliveSessions.ContainsKey(session.Id))
                {
                    _aliveSessions.Remove(session.Id);
                }
                session.InnerDispose();
            }
        }
예제 #3
0
        /// <summary>
        /// Mark chrome session as 'NotInUse'
        /// </summary>
        public static void ReleaseInstance(ChromeSession chromeSession)
        {
            const bool notInUse = false;

            ChromeSessions[chromeSession] = notInUse;
        }