public void Run(IWebDriver webDriver, Step step) { var e = ((ElementHasStyleStep)step); try { var element = ElementHelper.GetVisibleElement(webDriver, e.Element); string style = element.GetAttribute("style"); var styles = style.Split(';').Select(x => { var parts = x.Replace(" ", "").Split(':'); if (parts.Length != 2) return null; return new Style(parts[0], parts[1]); }).Where(x => x != null).ToList(); if (styles.All(x => x.Key != e.StyleKey)) throw new StepException(string.Format("The element '{0}' did not have the '{1}' style.", e.Element, e.StyleKey)); if (!styles.Any(x => x.Key == e.StyleKey && x.Value == e.StyleValue)) throw new StepException( string.Format("The element '{0}' had the '{1}' style, but it's value was not '{2}'.", e.Element, e.StyleKey, e.StyleValue)); } catch (NoSuchElementException ex) { throw new StepException(string.Format("The document does not contain an element that matches '{0}'.", e.Element)); } }
public IRestResponse Run(Step step, ScenarioContext context) { var apiStep = (ApiOptionsStep)step; var client = new RestClient(apiStep.Host); var restRequest = BuildRequest(apiStep); return client.Options(restRequest); }
public IRestResponse Run(Step s, ScenarioContext context) { var step = (ApiDeleteStep) s; var client = new RestClient(step.Host); var restRequest = BuildRequest(step); return client.Delete(restRequest); }
public IRestResponse Run(Step step, ScenarioContext context) { var apiPostStep = (ApiPutStep)step; var client = new RestClient(apiPostStep.Host); var restRequest = BuildRequest(apiPostStep); restRequest.AddBody(apiPostStep.RequestPayload); return client.Put(restRequest); }
public IBrowserStepStrategy Create(Step step) { IBrowserStepStrategy strategy = _stepStrategies.FirstOrDefault(x => x.IsFor(step.GetType())); if (strategy == null) throw new NotImplementedException( string.Format("No step strategies were available to handle the '{0}' strategy type.", step.GetType().Name)); return strategy; }
public virtual Step AddStep(Step step) { int lastOrder = 0; if (Steps.Any()) lastOrder = (Steps.OrderBy(x => x.Priority).Last()).Priority; step.SetPriority(lastOrder + 1); ((IList<Step>) Steps).Add(step); return step; }
public void Run(IWebDriver webDriver, Step step) { var s = ((ElementDoesNotExistStep)step); try { ElementHelper.GetVisibleElement(webDriver, s.Element, 5); } catch (ElementNotFoundException) { //all is good } }
public void Run(IWebDriver webDriver, Step step) { var s = ((SelectOptionStep) step); var element = ElementHelper.GetVisibleElement(webDriver, s.Element); var selectElement = new SelectElement(element); if (!string.IsNullOrEmpty(s.Value)) { selectElement.SelectByValue(s.Value); } else { selectElement.SelectByText(s.Text); } }
public void Run(IWebDriver webDriver, Step step) { var elementContainsStep = ((ElementHasClassStep)step); var elementSelector = elementContainsStep.Element; try { var element = ElementHelper.GetVisibleElement(webDriver, elementSelector); if (!element.GetAttribute("class").Contains(elementContainsStep.ClassName)) throw new StepException("The element did not have the given css class."); } catch (NoSuchElementException ex) { throw new StepException(string.Format("The document does not contain an element that matches '{0}'.", elementSelector)); } }
public void Run(IWebDriver webDriver, Step step) { var elementContainsStep = ((ElementContainsTextStep)step); var elementSelector = elementContainsStep.Element; try { var element = ElementHelper.GetVisibleElement(webDriver, elementSelector); var text = element.Text; if (!text.Contains(elementContainsStep.Text)) throw new StepException("The element did not contain the given text."); } catch (NoSuchElementException ex) { throw new StepException(string.Format("The document does not contain an element that matches '{0}'.", elementSelector)); } }
public void Run(IWebDriver webDriver, Step step) { var seconds = ((WaitStep)step).Seconds; Thread.Sleep(seconds*1000); }
public LinkedStep(Step step, IEnumerable<StepRunResult> results) { Step = step; Results = results; }
public void Run(IWebDriver webDriver, Step step) { var s = (PressKeyStep) step; var ch = (char) s.KeyCode; webDriver.FindElement(By.CssSelector(s.Element)).SendKeys(ch.ToString()); }
public void Run(IWebDriver webDriver, Step step) { webDriver.Navigate().GoToUrl(((NavigateStep)step).Url); }
public virtual void RemoveStep(Step step) { ((IList<Step>) Steps).Remove(step); }
public void Run(IWebDriver webDriver, Step step) { string buttonSelector = ((ClickStep) step).Element; IWebElement element = ElementHelper.GetVisibleElement(webDriver, buttonSelector); element.Click(); }
public void Run(IWebDriver webDriver, Step step) { var s = ((ElementExistsStep)step); ElementHelper.GetVisibleElement(webDriver, s.Element); }
public void Run(IWebDriver webDriver, Step step) { var enterTextStep = ((EnterTextStep)step); var element = ElementHelper.GetVisibleElement(webDriver, enterTextStep.Element); element.SendKeys(enterTextStep.Text); }
public IApiStepStrategy Create(Step step) { return _stepStrategies.First(x => x.IsFor(step.GetType())); }
public StepNotApiStepException(Step step):base(string.Format("Step is not an API Step: {0}", step.GetDescription())) { }
public void Run(IWebDriver webDriver, Step step) { var s = ((WaitForElementStep) step); ElementHelper.GetVisibleElement(webDriver, s.Element, s.Seconds); }
object MapStep(Step step) { return _mappingEngine.Map<Step, StepDetailResponse>(step); }