public IWebDriver Frame(string nameOrId)
        {
            logger_.Verbose("('{0}')", nameOrId);
            // Finding the target element so we can report it.
            // We use find elements(plural) to avoid exception when the element
            // is not found.
            logger_.Verbose("Getting frames by name...");
            ReadOnlyCollection <IWebElement> frames = driver_.FindElementsByName(nameOrId);

            if (frames.Count == 0)
            {
                logger_.Verbose("No frames found! Trying by id...");
                // If there are no frames by that name, we'll try the id
                frames = driver_.FindElementsById(nameOrId);
                if (frames.Count == 0)
                {
                    // No such frame, bummer
                    throw new NoSuchFrameException($"No frame with name or id '{nameOrId}' exists!");
                }
            }
            logger_.Verbose("Done! Making preparations...");
            WillSwitchToFrame_(frames[0]);
            logger_.Verbose("Done! Switching to frame {0}...", nameOrId);
            targetLocator_.Frame(nameOrId);
            logger_.Verbose("Done!");
            return(driver_);
        }
Esempio n. 2
0
        public IWebDriver Frame(string nameOrId)
        {
            logger_.Log(TraceLevel.Debug, Stage.General, StageType.Called, new { nameOrId });
            // Finding the target element so we can report it.
            // We use find elements(plural) to avoid exception when the element
            // is not found.
            ReadOnlyCollection <IWebElement> frames = driver_.FindElementsByName(nameOrId);

            if (frames.Count == 0)
            {
                // If there are no frames by that name, we'll try the id
                frames = driver_.FindElementsById(nameOrId);
                if (frames.Count == 0)
                {
                    // No such frame, bummer
                    throw new NoSuchFrameException($"No frame with name or id '{nameOrId}' exists!");
                }
            }
            WillSwitchToFrame_(frames[0]);
            return(driver_);
        }