Esempio n. 1
0
        /// <summary>
        /// Switches focus to the specified frame, by index, name or WebElement.
        /// </summary>
        /// <param name="identifier">The name, id, or WebElement of the frame to switch.</param>
        /// <param name="timeout">Optional timeout in milliseconds</param>
        public void SwitchToFrame(object identifier, int timeout)
        {
            if (identifier == null)
            {
                throw new Errors.ArgumentError("Invalid type for argument identifier");
            }

            var element = identifier as WebElement;

            if (element != null)
            {
                identifier = element.SerializeJson();
            }

            try {
                _session.Send(RequestMethod.POST, "/frame", "id", identifier);
            } catch (Errors.NoSuchFrameError) {
                if (timeout == 0)
                {
                    throw;
                }
                var endTime = _session.GetEndTime(timeout);
                while (true)
                {
                    SysWaiter.Wait();
                    try {
                        _session.SendAgain();
                        break;
                    } catch (Errors.NoSuchFrameError) {
                        if (DateTime.UtcNow > endTime)
                        {
                            throw;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 internal static List GetWindowsHandles(RemoteSession session)
 {
     return((List)session.Send(RequestMethod.GET, "/window_handles"));
 }
Esempio n. 3
0
 internal static string ActivateWindow(RemoteSession session, string name)
 {
     session.Send(RequestMethod.POST, "/window", "name", name);
     return((string)session.Send(RequestMethod.GET, "/window_handle"));
 }
Esempio n. 4
0
 internal static string GetCurrentTitle(RemoteSession session)
 {
     return((string)session.Send(RequestMethod.GET, "/title"));
 }