ไม้โปรแทรกเตอร์ - แตงกวาไม่เลือกค่าจากตัวอย่าง

ไม้โปรแทรกเตอร์ - แตงกวาไม่เลือกค่าจากตัวอย่าง ฉันใช้ไซต์ http://juliemr.github.io/protractor-demo/ ในกล่องข้อความแรกที่ป้อน <key1> และ <key2>

ไฟล์คุณสมบัติอยู่ด้านล่าง

คุณลักษณะ: นำทางไปยังไซต์เครื่องคิดเลขและเพิ่มตัวเลขสองตัว

สถานการณ์จำลอง: เพิ่มตัวเลขสองตัวโดยใช้ไซต์เครื่องคิดเลข

ให้นำทางไปยัง url ไซต์เครื่องคิดเลข http://juliemr.github.io/protractor-demo/

เมื่อระบุตัวเลขสองตัวเพื่อเพิ่มหมายเลขแรก < key1 > และ < key2 >

จากนั้นคลิกที่ปุ่มเพิ่มบนเว็บไซต์เครื่องคิดเลข

โครงร่างสถานการณ์: ระบุพารามิเตอร์

ตัวอย่าง:

| key1 | key2 |
|  2   |  3   |
|  2   | 60   |

ไฟล์คำจำกัดความขั้นตอน

import { Given, When, Then } from "cucumber";
import { browser } from "protractor";
import { calculator } from "../pageObjects/calculator";

let cal = new calculator();
Given('Navigate to calculator site url {string}', async (string)=> {
    // Write code here that turns the phrase above into concrete actions
    await browser.get(string);
});

When('Provide two numbers to add first number {string} and {string}', async (firstValue:string, 
secondvalue:string)=> {
    // Write code here that turns the phrase above into concrete actions
    await cal.firstEditBox.sendKeys(firstValue);
    await cal.secondEditBox.sendKeys(secondvalue);
});

Then('Click on add button on calculator site', async ()=> {
    // Write code here that turns the phrase above into concrete actions
    await cal.goButton.click;
    cal.getResult.getText().then(function(text) {
      console.log(text);
    })
});

ข้อผิดพลาด ภาพหน้าจอของไซต์เครื่องคิดเลข


person Abhishek Sharma    schedule 18.07.2020    source แหล่งที่มา
comment
stackoverflow.com/a/22661443/8903949   -  person Bharath Kumar S    schedule 18.07.2020
comment
ไม่เข้าใจว่าฉันใช้ Protractor กับ Typescript พยายามใช้แตงกวาด้วย   -  person Abhishek Sharma    schedule 18.07.2020
comment
โปรดดูคำตอบด้านล่าง   -  person Bharath Kumar S    schedule 18.07.2020


คำตอบ (2)


ไฟล์คุณสมบัติ

Feature: To search keywords in google

@OutlineScenario
Scenario Outline: Searching on google
  
  Given I am on "<search>" search page
  When I type "<search keyword>"
  Then I click on search button
  Then I clear the search text

  Examples:
    | search | search keyword | 
    |  google   | cucumber |
    |  cucumber | protractor |
    |  protractor | typescript | 

ขั้นตอนแน่นอน

 Given(/^I am on "(.*?)" search page$/, async (text) => {
     if (text === "google") {
         await expect(browser.getTitle()).to.eventually.equal("Google");
     } else if (text === "cucumber") {
         await expect(browser.getTitle()).to.eventually.equal(text + " - Google Search");
     } else if (text === "protractor") {
         await expect(browser.getTitle()).to.eventually.equal(text + " - Google Search");
     } 
 });

When(/^I type "(.*?)"$/, async (text) => {
    await search.searchTextBox.sendKeys(text);
});
person Bharath Kumar S    schedule 18.07.2020
comment
ฉันทำเช่นเดียวกัน แต่กำลังเลือกค่าเป็น ‹key1› ขั้นตอนที่แน่นอน ฉันกำลังใช้สิ่งเหล่านั้นสร้างขึ้นโดยค่าเริ่มต้นโดย Visual Studio Code - person Abhishek Sharma; 18.07.2020
comment
โปรดทำซ้ำโค้ดของฉันในข้อมูลโค้ดของคุณซึ่งควรจะใช้งานได้ - person Bharath Kumar S; 18.07.2020

โปรดระบุ Scenario Outline: แทน Scenario: ในบรรทัดแรกของไฟล์ Feature ของคุณ แล้วจะได้รับการแก้ไข มิฉะนั้นทุกอย่างก็โอเคในรหัสของคุณ มันควรจะเป็นดังนี้:

 Scenario Outline: Add two number using calculator site

โครงร่างสถานการณ์: ระบุพารามิเตอร์- โปรดลบบรรทัดนี้ออกจากไฟล์ฟีเจอร์ของคุณ

person arpita biswas    schedule 26.08.2020