0

I have a Website where the userID differs for every login, Say for example When i login with userID 'Username1' this contains 0 to 8 characters, similarly if i login with userID 'Username123' contains 0 to 10 characters

I need to automate in such a way, that for every login system stores the user ID in a variable as follows

String FullUsername=driver.findElement(MyTeamInboxPage.username).getText();

My result for the userID 'Username1' would be Username1

I am gonna take substring from 4 to till end as follows

String actual=Fullactual.substring(4, 8);

But the sub string code will not work for every userID. How can i change my SubString code end character alone in such a way, it should work for every User ID

1 Answer 1

1

You can try:

String actual=Fullactual.substring(4, Fullactual.length());

Note: the endIndex of substring is exclusive. That means if you want to take a substring upto index 8, endIndex has to be 9. That's why I used Fullactual.length(), not Fullactual.length()-1

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. It actually worked :-) :-) ......Thanks for the immediate response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.