From 95dd3caf4b90b2d42aa1d5b35b0fd48504f802c3 Mon Sep 17 00:00:00 2001 From: Viktor Pergjoka Date: Tue, 31 Oct 2017 18:41:40 +0100 Subject: [PATCH] doc(tutorial): added example for element.getAttribute('value') to read text from an input (#4566) * added example for element.getAttribute('value') in tutorial --- docs/tutorial.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/tutorial.md b/docs/tutorial.md index 7a9946fc0..e87758913 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -144,11 +144,18 @@ describe('Protractor Demo App', function() { // Fill this in. expect(latestResult.getText()).toEqual('10'); }); + + it('should read the value from an input', function() { + firstNumber.sendKeys(1); + expect(firstNumber.getAttribute('value')).toEqual('1'); + }); }); ``` Here, we've pulled the navigation out into a `beforeEach` function which is run before every `it` block. We've also stored the ElementFinders for the first and second input in nice variables that can be reused. Fill out the second test using those variables, and run the tests again to ensure they pass. +In the last assertion we read the value from the input field with `firstNumber.getAttribute('value')` and compare it with the value we have set before. + Step 3 - changing the configuration -----------------------------------