user2724402
user2724402

Reputation: 19

Click on a button by using Rosource Id in robotium scripts

I need a help regarding robotium scripts.

I have the source code for the button

Button btnCreateTask = (Button) findViewById(R.id.btnCreateTask);

I want to click on button using robotium I used the following code for it

Button CTButton = solo.getView(R.id.btnCreateTask);
solo.clickOnView(CTButton);

But I am getting an error like "btnCreateTask cannot be resolved or is not a field" Can anyone please help me why this error is coming. Is this the correct way I am using? Thanks

Upvotes: 0

Views: 881

Answers (1)

Flavio Capaccio
Flavio Capaccio

Reputation: 706

Correct code is:

Button CTButton = solo.getView("btnCreateTask");
solo.clickOnView(CTButton);

Upvotes: 2

Related Questions