public void TestDogApiStatusCode()
        {
            // This test shows how to call a REST API without parsing response content.

            var request  = DogRequests.GetRandomDog();
            var response = Actor.Calls(Rest.Request(request));

            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
 /// <summary>
 /// Scrolls directly to an element using JavaScript.
 /// </summary>
 /// <param name="actor">The Screenplay Actor.</param>
 /// <param name="driver">The WebDriver.</param>
 public override void PerformAs(IActor actor, IWebDriver driver)
 {
     if (Top != null)
     {
         actor.Calls(JavaScript.On(Locator, $"arguments[0].scrollTop = {Top};"));
     }
     if (Left != null)
     {
         actor.Calls(JavaScript.On(Locator, $"arguments[0].scrollLeft = {Left};"));
     }
 }
        public byte[] RequestAs(IActor actor)
        {
            var request  = DogRequests.GetRandomDog();
            var response = actor.Calls(DogApi.Request <DogResponse>(request));

            var resource     = new Uri(response.Data.Message).AbsolutePath;
            var imageRequest = new RestRequest(resource);
            var extension    = Path.GetExtension(resource);
            var imageData    = actor.Calls(DogImagesApi.Download(imageRequest, extension));

            return(imageData);
        }
        public void WhenICreateANewCarResourceWithTheFollowingDetails(Table table)
        {
            var values = table.Rows.Single();

            int customerId = _actor.AsksFor(StoredCustomerId.ForName(values["Customer"]));

            _newCarInput = new CarInfo
            {
                Registration        = values["Registration"],
                CustomerId          = customerId,
                Make                = values["Make"],
                Model               = values["Model"],
                MotExpiry           = values.GetDateOrDefault("MOT Expiry"),
                SuppressMotReminder = values.GetBool("Suppress MOT Reminder")
            };

            _lastResponse.Response = _actor.Calls(Post.Resource(_newCarInput).To("api/car"));
        }
        public void TestDogApi()
        {
            var request  = DogRequests.GetRandomDog();
            var response = Actor.Calls(Rest <CallDogApi> .Request <DogResponse>(request));

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            response.Data.Status.Should().Be("success");
            response.Data.Message.Should().NotBeNullOrWhiteSpace();
        }
Example #6
0
        public void WhenICreateANewCustomerResourceWithTheFollowingDetails(Table table)
        {
            var values = table.Rows.Single();

            _newCustomerInput = new CustomerInfo
            {
                Title               = values["Title"],
                Name                = values["Name"],
                AddressLine1        = values["Address Line 1"],
                AddressLine2        = values["Address Line 2"],
                AddressLine3        = values["Address Line 3"],
                Postcode            = values["Postcode"],
                HomePhone           = values["Home Phone"],
                Mobile              = values["Mobile"],
                HasAccountInvoicing = values.GetBoolOrDefault("Account Invoicing")
            };

            _lastResponse.Response = _actor.Calls(Post.Resource(_newCustomerInput).To("api/customer"));
        }
 /// <summary>
 /// Gets a web element's JavaScript textContent value.
 /// </summary>
 /// <param name="actor">The actor.</param>
 /// <param name="driver">The WebDriver.</param>
 /// <returns></returns>
 public override string RequestAs(IActor actor, IWebDriver driver) =>
 actor.Calls(JavaScript <string> .On(Locator, "return arguments[0].textContent;")).ToString();
Example #8
0
 /// <summary>
 /// Clicks the web element.
 /// Use browser actions instead of direct click (due to IE).
 /// </summary>
 /// <param name="actor">The Screenplay Actor.</param>
 /// <param name="driver">The WebDriver.</param>
 public override void PerformAs(IActor actor, IWebDriver driver) =>
 actor.Calls(JavaScript.On(Locator, "arguments[0].click();"));