How to skip row when for loop is executing and row is emptyHow does the Java 'for each' loop work?How do I time a method's execution in Java?Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow can I create an executable JAR with dependencies using Maven?How do I break out of nested loops in Java?Unable to read excel if cell/column has drop down list enabled for Selenium webdriver TestNGBlank rows is skipped while reading data from the excel sheetHow to extract double int value from excel sheet using seleniumHow to get column values from an excel using only column name?how can i use TestNg assertion method in for loop
Bookshelves: the intruder
Have the writers and actors of Game Of Thrones responded to its poor reception?
Does science define life as "beginning at conception"?
What's is the easiest way to purchase a stock and hold it
Why is so much ransomware breakable?
Why does snapping your fingers activate the Infinity Gauntlet?
How to convince boss to spend notice period on documentation instead of new projects
"File type Zip archive (application/zip) is not supported" when opening a .pdf file
How could the B-29 bomber back up under its own power?
Isn't Kirchhoff's junction law a violation of conservation of charge?
How do we explain the use of a software on a math paper?
Bash Array of Word-Splitting Headaches
Warped chessboard
Novel where a cube cooled below absolute zero makes a hole in reality
What were the "pills" that were added to solid waste in Apollo 7?
How do I unravel apparent recursion in an edef statement?
Bash - Execute two commands and get exit status 1 if first fails
Easier way to draw a filled ellipse with top edge dashed and bottom edge solid?
If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?
Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?
FIFO data structure in pure C
Why didn't Daenerys' advisers suggest assassinating Cersei?
Why is python script running in background consuming 100 % CPU?
Can't think of a good word or term to describe not feeling or thinking
How to skip row when for loop is executing and row is empty
How does the Java 'for each' loop work?How do I time a method's execution in Java?Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow can I create an executable JAR with dependencies using Maven?How do I break out of nested loops in Java?Unable to read excel if cell/column has drop down list enabled for Selenium webdriver TestNGBlank rows is skipped while reading data from the excel sheetHow to extract double int value from excel sheet using seleniumHow to get column values from an excel using only column name?how can i use TestNg assertion method in for loop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have 2 excel sheets, I am comparing cell values using the testNg
Assertion. Following are the values in sheet1 and sheet2, after david
, I have an empty row in both the sheets, my script is failing since row 3 is blank and it's not going to row 4?
Sheet1 Sheet2
sachin sachin
david david
winter winter
I have written following code:-
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
Need correct code, it should skip the 3rd row since it has blank value and move to 4th row and compare and pass the script.
java selenium
add a comment |
I have 2 excel sheets, I am comparing cell values using the testNg
Assertion. Following are the values in sheet1 and sheet2, after david
, I have an empty row in both the sheets, my script is failing since row 3 is blank and it's not going to row 4?
Sheet1 Sheet2
sachin sachin
david david
winter winter
I have written following code:-
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
Need correct code, it should skip the 3rd row since it has blank value and move to 4th row and compare and pass the script.
java selenium
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57
add a comment |
I have 2 excel sheets, I am comparing cell values using the testNg
Assertion. Following are the values in sheet1 and sheet2, after david
, I have an empty row in both the sheets, my script is failing since row 3 is blank and it's not going to row 4?
Sheet1 Sheet2
sachin sachin
david david
winter winter
I have written following code:-
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
Need correct code, it should skip the 3rd row since it has blank value and move to 4th row and compare and pass the script.
java selenium
I have 2 excel sheets, I am comparing cell values using the testNg
Assertion. Following are the values in sheet1 and sheet2, after david
, I have an empty row in both the sheets, my script is failing since row 3 is blank and it's not going to row 4?
Sheet1 Sheet2
sachin sachin
david david
winter winter
I have written following code:-
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
Need correct code, it should skip the 3rd row since it has blank value and move to 4th row and compare and pass the script.
java selenium
java selenium
edited Mar 23 at 22:11
TheChubbyPanda
98511025
98511025
asked Mar 23 at 18:12
Lokesh B CLokesh B C
31
31
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57
add a comment |
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57
add a comment |
2 Answers
2
active
oldest
votes
Use the continue
statement.
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
try
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
catch (Exception e)
continue;
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
add a comment |
You could set the loop from i to i<=2.
Following that loop, do another loop from i=4 to i <=rowCount.
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316899%2fhow-to-skip-row-when-for-loop-is-executing-and-row-is-empty%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use the continue
statement.
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
try
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
catch (Exception e)
continue;
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
add a comment |
Use the continue
statement.
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
try
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
catch (Exception e)
continue;
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
add a comment |
Use the continue
statement.
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
try
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
catch (Exception e)
continue;
Use the continue
statement.
int rowCount = xlib.getRowCount("Sheet1");
for (int i = 0; i<=rowCount;i++)
try
String compair1= xlib.getExcelData("Sheet1", i, 0);
System.out.println(compair1);
String compair2=xlib.getExcelData("Sheet2", i, 0);
System.out.println(compair2);
Assert.assertEquals(compair1, compair2);
System.out.println("compared successfully");
catch (Exception e)
continue;
answered Mar 23 at 18:20
TheChubbyPandaTheChubbyPanda
98511025
98511025
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
add a comment |
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
Thanks that helped !!! But I have another challenge, I am having some rows with date format (mm-dd-yyyy) , it is failing to read that entry , it is saying text cell value as numeric, is there any way, I can read the date format and compare both the sheets or should I need to change the date format in the excel itself?
– Lokesh B C
Mar 23 at 18:39
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
That counts as another question and hence should be separate from this one. Please ask a separate question regarding this issue.
– TheChubbyPanda
Mar 23 at 18:42
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
@LokeshBC Please mark this question as solved.
– TheChubbyPanda
Mar 23 at 20:52
add a comment |
You could set the loop from i to i<=2.
Following that loop, do another loop from i=4 to i <=rowCount.
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
add a comment |
You could set the loop from i to i<=2.
Following that loop, do another loop from i=4 to i <=rowCount.
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
add a comment |
You could set the loop from i to i<=2.
Following that loop, do another loop from i=4 to i <=rowCount.
You could set the loop from i to i<=2.
Following that loop, do another loop from i=4 to i <=rowCount.
answered Mar 23 at 18:15
TheButterWormTheButterWorm
156
156
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
add a comment |
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
this is one example, but actually I have to 50 rows, some are blank in the middle, I cannot use many loops instead can I get something if statement stating if row is blank skip and move to next row like that?
– Lokesh B C
Mar 23 at 18:21
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
Oh in that case, TheChubbyPanda's answer should be what you're looking for.
– TheButterWorm
Mar 23 at 18:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316899%2fhow-to-skip-row-when-for-loop-is-executing-and-row-is-empty%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Add check for the value compair1 or compair2 to be null, and if so don't Assert.
– VSB
Mar 23 at 18:15
You could just clean up your data... or grab all data and filter out empties.
– JeffC
Mar 25 at 21:57