Home > Software engineering >  Pass an element get text value in other step definition in cucumber
Pass an element get text value in other step definition in cucumber

Time:04-16

I am writing a code wherein I am retrieving text from a web element and I want to use that same text in other step definition in cucumber. My code is as follows

String researchticketId;

@When("A research ticket with risk rating {int} is created or selected")
    public void a_research_ticket_with_risk_rating_is_created_or_selected(Integer int1) {
        researchticketId=rs.getrefidlist().get(0).getText();
        System.out.println(researchticketId);
        WaitActions.wait(3000);
    }

@Then("It should be displayed in In research tab with Complexity as No known difficulty")
    public void it_should_be_displayed_in_in_research_tab_with_complexity_as_no_known_difficulty() {
        rs.gettabslist().get(1).click();
        //rs.findresearchticketId(researchticketId);
        System.out.println(researchticketId);
        WaitActions.wait(5000);
        //Assert.assertEquals(researchticketId, rs.getrefidlist().get(0).getText());


    }

In Then step, no value is been passed in researchticketId variable. Because of which my tests keep on failing. Can anyone please help me on this?

CodePudding user response:

It got fixed. I used getAttribute("innerHTML") and it captured by text. This approach is correct by the way.

  • Related