Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
How to skip one click action in between of loop

I am currently running one script where there is a search box and I am entering some keywords in it and searching for the result. All the keywords are coming from excel sheet one by one so I have used "for loop" to achieve this. Now in this loop first time when I search for keyword, in next step, I have to click on one element which I already have written in my script however when loop runs second time, I don't need to click on that element because it is already clicked, now my script is getting failed because in the second time webdriver is not able to click on that element, I have tried with isdisplayed(), isenalbled() function but nothing is working. so what could be the best option to skip one step of click in loop from the second time. I know the last option to achieve this will be try catch but I dont want to use it, please suggest

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When your button get clicked for first time , use one boolean variable and assign true to it. When second time loop runs and find that boolean variable is true or not and if yes then use "continue;" in your java code.

boolean isClicked = false;
For(int i=0; i<=some_value;i++) {
if(!isCliecked){ 
WebElement.clicked Searchbox.sendkeys("mykeywords") } 
isClicked = true;
}else{
 continue;
 }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!