के लिए पाठ बॉक्स के लिए लिख मेरी HTML दस्तावेज़ में के बाद पाठ पढ़ने के लिए कोशिश कर रहा है मैं निम्नलिखित कोड है:कोणमापक: E2E परीक्षण
<label class="field" for="first_name">First Name:</label>
<span class="pull-right"><input type="text" id="first_name">
name="first_name" ng-model="first_name">
</span>
यह मैं एक लेबल के साथ एक पाठ बॉक्स इसके बगल में दे देंगे और कहा, "पहला नाम "।
मैं तो पाठ बॉक्स में अपना नाम लिखने के निम्नलिखित कोड का उपयोग कर:
element(by.model('first_name')).sendKeys('Frank');
इस कोड को टेक्स्ट बॉक्स में फ्रैंक लिखेंगे, लेकिन अब मेरा लक्ष्य बनाने के लिए पाठ बॉक्स से पाठ पढ़ने के लिए प्रयास करने के लिए है सुनिश्चित करें कि यह वास्तव में मेरा नाम लिखा था। मुझे यह करने में बहुत परेशानी हो रही है।
मैं पाठ बॉक्स से पढ़ने के लिए निम्नलिखित कोड का उपयोग कर की कोशिश की:
expect(element(by.model('first_name')).getText()).to.equal('Frank');
लेकिन मैं इस त्रुटि मिलती है:
console.log(element(by.model('first_name')).getText());
:
AssertionError: expected { Object (locator_, parentElementFinder_, ...) } to equal 'Frank'
इसके अलावा जब मैं एक करने की कोशिश
मुझे यह त्रुटि मिलती है:
{ locator_: { findElementsOverride: [Function], toString: [Function: toString] }, parentElementFinder_: null, opt_actionResult_: { then: [Function: then], cancel: [Function: cancel], isPending: [Function: isPending] }, opt_index_: undefined, click: [Function], sendKeys: [Function], getTagName: [Function],
getCssValue: [Function], getAttribute: [Function], getText: [Function], getSize: [Function], getLocation: [Function],
isEnabled: [Function], isSelected: [Function], submit: [Function], clear: [Function], isDisplayed: [Function], getOuterHtml: [Function], getInnerHtml: [Function], toWireValue: [Function] }
getAttribute('value')
का उपयोग करने का प्रयास करते समय मुझे यह वही त्रुटि मिलती है। मुझे यकीन नहीं है कि त्रुटि का अर्थ वास्तव में क्या है और मुझे यह सुनिश्चित नहीं है कि मैं console.log()
का उपयोग करते समय क्या देख रहा हूं। मैं protractor का उपयोग करने के लिए थोड़े नए हूँ। किसी भी मदद की बहुत सराहना की जाती है और समय से पहले धन्यवाद।
संपादित करें: पूर्ण spec.js
var chai = require('chai'),
chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
expect = chai.expect;
before(function() {
// suite wide initial setup here
browser.get("http://127.0.0.1:5000/");
browser.waitForAngular();
});
it('Should redirect and load template',function(){
element(by.id('authentication'))
.element(by.css('.text-center'))
.element(by.linkText('Click here'))
.click();
expect(browser.getCurrentUrl()).to.eventually.have.string('/#/home');
});
it('Should Enter name into text box', function(){
element(by.model('first_name')).sendKeys('Frank');
expect(element(by.model('first_name')).getAttribute('value'))
.to.equal('Frank');
});
मैंने पहले से ही यह कोशिश की है लेकिन मुझे एक ही त्रुटि मिल रही है: AssertionError: अपेक्षित {ऑब्जेक्ट (locator_, parentElementFinder_, ...)} बराबर 'फ्रैंक' – Frank
@ फ्रैंकइन्साना क्या आप अपने spec का पूरा कोड पोस्ट कर सकते हैं और नोट कर सकते हैं प्रोटैक्टर संस्करण आप उपयोग कर रहे हैं? धन्यवाद। – alecxe
ओएमजी मैं तुमसे प्यार करता हूँ !!! यह काम करता हैं!! मैंने ".then" का उपयोग करने की कोशिश की लेकिन स्पष्ट रूप से मैं इसे गलत कर रहा था। वाह धन्यवाद!! +1 – Frank