Code Monkey home page Code Monkey logo

Comments (7)

aslakhellesoy avatar aslakhellesoy commented on July 3, 2024

So you have a step:

And Sales Tax Rate is 10 Percent

which has the following step text: Sales Tax Rate is 10 Percent

You have defined two step definitions:

@Given("Sales Tax Rate is {int} Percent")
public void sales_Tax_Rate_is_Percent(Integer taxRate) {
    // Write code here that turns the phrase above into concrete actions
   this.TaxRate = taxRate;
   System.out.println("Tax Rate: " + taxRate);
}

@Given("Sales Tax Rate is {double} Percent")
public void sales_Tax_Rate_is_Percent(Double taxRate) {
    this.TaxRate = taxRate;
    System.out.println("Tax Rate: " + taxRate);
}

Their expressions both match the step text, so Cucumber cannot determine which one you want to run. You have to remove the ambiguity. It's a bit like defining the same method twice. It's a kind of compile error.

I suggest you remove the first one and try again.

from cucumber-java-skeleton.

DThomas221 avatar DThomas221 commented on July 3, 2024

Hey aslakhellesoy,

I also add a few more information

from cucumber-java-skeleton.

aslakhellesoy avatar aslakhellesoy commented on July 3, 2024

I assume you are happy with this answer. If not, please reopen.

from cucumber-java-skeleton.

DThomas221 avatar DThomas221 commented on July 3, 2024

No, how do I reopen this question

from cucumber-java-skeleton.

DThomas221 avatar DThomas221 commented on July 3, 2024

What about the multiple markers at this line??

from cucumber-java-skeleton.

aslakhellesoy avatar aslakhellesoy commented on July 3, 2024

Multiple markers at what line??

Please use the support forums for questions and discussions. We use GitHub issues to track bugs and contributions exclusively.

from cucumber-java-skeleton.

DThomas221 avatar DThomas221 commented on July 3, 2024

100019209-437b3800-2da3-11eb-8b3e-5ccfcaf0637f
100019241-51c95400-2da3-11eb-91d9-513e852396a5

int InitalBillAmount;
double TaxRate;

@given("I have a Customer")
public void i_have_a_Customer() {

}

@given("user enters intial bill amount as {int}")
public void user_enters_intial_bill_amount_as(Integer initialBillAmount) {
this.InitalBillAmount = initialBillAmount;
System.out.println("InitialBillAmount: " + initialBillAmount);
}

@given("Sales Tax Rate is {int} Percent")
public void sales_Tax_Rate_is_Percent(Integer taxRate) {
// Write code here that turns the phrase above into concrete actions
this.TaxRate = taxRate;
System.out.println("Tax Rate: " + taxRate);
}

@then("final bill amount calculated is {int}")
public void final_bill_amount_calculate_is(Integer expectedValue) {
double SystemCalcValue =
BillCalculationHelper.CalculateBillForCustomer(this.InitalBillAmount, this.TaxRate);
System.out.println("Expected Value: " + expectedValue);
System.out.println("Calculated Value: " + SystemCalcValue);
assertTrue(expectedValue == SystemCalcValue);

}

@given("Sales Tax Rate is {double} Percent")
public void sales_Tax_Rate_is_Percent(Double taxRate) {
this.TaxRate = taxRate;
System.out.println("Tax Rate: " + taxRate);
}

private void invokeWebPage(Double expectedValue) {
System.setProperty("webdriver.chrome.driver", "C:\ChromeDriver\chromedriver.exe");

ChromeDriver driver = new ChromeDriver();

driver.get("http://localhost:8080/BasicWebsite/Index.jsp");

WebElement BillAmountTextBox = driver.findElement(By.id("billamount"));

WebElement TaxRateTextBox = driver.findElement(By.id("taxrate"));

WebElement Button = driver.findElement(By.id("mybutton"));

BillAmountTextBox.sendKeys(Integer.toString(InitalBillAmount));

TaxRateTextBox.sendKeys(Double.toString(TaxRate));

Button.click();

WebElement Header1Element = driver.findElementByXPath("//h1");

System.out.println(Header1Element.getText());

boolean Matched = Header1Element.getText().contains("Final Bill Amount is: $" + expectedValue.toString());

System.out.println(Matched);

}

@then("final bill amount calculated is {double}")
public void final_bill_amount_calculate_is(Double expectedValue) {
double SystemCalcValue =
BillCalculationHelper.CalculateBillForCustomer(this.InitalBillAmount, this.TaxRate);
System.out.println("Expected Value: " + expectedValue);
System.out.println("Calculated Value: " + SystemCalcValue);
assertTrue(expectedValue == SystemCalcValue);
invokeWebPage(expectedValue);

}

from cucumber-java-skeleton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.