Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to put check condition inside for loop, gives error (PR fix committed) #423

Closed
ShwetaChahan opened this issue May 13, 2019 · 4 comments
Labels

Comments

@ShwetaChahan
Copy link

ShwetaChahan commented May 13, 2019

allValues="changeStatusTo"
js begin
tempArr=allValues.split("/");
noOfStatus=tempArr.length;
console.log(noOfStatus);
js finish
for n from 0 to noOfStatus-1
{
status=tempArr[n]
if tempArr[n] equals to "abc"
{
//do some actions
check present('//div[contains(@Class,"forcePageError")]') | "Error Message is displayed" | "Error Message is not displayed"

}

}

@kensoh
Copy link
Member

kensoh commented May 13, 2019

Hi Shweta, do you have a website with the minimum replication steps, and the error message you get?

@kensoh kensoh added the query label May 13, 2019
@ShwetaChahan
Copy link
Author

Hi Ken, You can reproduce using any website. Its just that when you paste the check outside the for loop, it works.
Below code will not work. It gives syntax error. But when you paste the check outside the for loop, it stops giving syntax error.
https://www.bing.com
allValues="Incoming/Outgoing"
js begin
tempArr=allValues.split("/");
noOfStatus=tempArr.length;
console.log(noOfStatus);
js finish
for n from 0 to noOfStatus-1
{
status=tempArr[n]
if tempArr[n] equal to "Incoming"
{
//do some actions

check present('//div[contains(@Class,"forcePageError")]') | "Error Message is displayed" | "Error Message is not displayed"	
}

}

@kensoh kensoh added bug and removed query labels May 13, 2019
kensoh added a commit to tebelorg/TagUI that referenced this issue May 13, 2019
aisingapore#423

update summary - check step was not originally designed to work in for loops. this update allows check step to work in for loops, and also adds test cases to verify that check step can work within for loops.

technical details - check step will insert an if block into the code block that immediately closes without normal processing line by line. this will cause TagUI to be mistaken that parsing is still within an if block and not handling a for loop block as it should be handled. in this change, a helper function check_intent_clear_injected_if_block() is added and called during parsing of check step to update TagUI internal tracking that the if block has been closed at end of the check step. that allows for loops to function correctly when check step is used within a loop.
kensoh added a commit that referenced this issue May 13, 2019
#423 - enable check step within for loop

**update summary** - check step was not originally designed to work in for loops. this update allows check step to work in for loops, and also adds test cases to verify that check step can work within for loops.

**technical details** - check step will insert an if block into the code block that immediately closes without normal processing line by line. this will cause TagUI to be mistaken that parsing is still within an if block and not handling a for loop block as it should be handled. in this change, a helper function check_intent_clear_injected_if_block() is added and called during parsing of check step to update TagUI internal tracking that the if block has been closed at end of the check step. that allows for loops to function correctly when check step is used within a loop.
@kensoh
Copy link
Member

kensoh commented May 13, 2019

Good catch Shweta, thanks! Created PR and committed to master with following comments -

update summary - check step was not originally designed to work in for loops. this update allows check step to work in for loops, and also adds test cases to verify that check step can work within for loops.

technical details - check step will insert an if block into the code block that immediately closes without normal processing line by line. this will cause TagUI to be mistaken that parsing is still within an if block and not handling a for loop block as it should be handled. in this change, a helper function check_intent_clear_injected_if_block() is added and called during parsing of check step to update TagUI internal tracking that the if block has been closed at end of the check step. that allows for loops to function correctly when check step is used within a loop.

Prior to a future packaged release, this update is available from TagUI cutting edge version here -

https://github.com/kelaberetiv/TagUI#set-up

@kensoh kensoh changed the title Unable to put check condition inside for loop, gives error Unable to put check condition inside for loop, gives error (PR and fix committed) May 13, 2019
@kensoh kensoh changed the title Unable to put check condition inside for loop, gives error (PR and fix committed) Unable to put check condition inside for loop, gives error (PR fix committed) May 13, 2019
@ShwetaChahan
Copy link
Author

Thank you so much Ken for the quick fix. It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants