Forum Discussion

tarleaa's avatar
tarleaa
Contributor
15 years ago

Do ... While in Error Log

Hello, 


I have the following code :


function Test()

{



......



do

{

//login

table = page2.Form("aspnetForm").Panel("divWrapper").Panel("ctl00_sectionHeader").Panel(0).Panel("ctl00_UcHeader_sectionLogin").Panel("ctl00_UcHeader_UcHeaderLogin_Panel1").Table("ctl00_UcHeader_UcHeaderLogin_tableNotLogged");

table.Cell(0, 1).Textbox("ctl00_UcHeader_UcHeaderLogin_txtUsername").Text = "username";

table.Cell(1, 1).PasswordBox("ctl00_UcHeader_UcHeaderLogin_txtPassword").Text = "test01";

table.Cell(2, 0).Panel(0).ImageButton("ctl00_UcHeader_UcHeaderLogin_btnLogin").Click();

//Please wait until download completes:...

page2.Wait();

}



while (page2.Form("aspnetForm").Panel("divWrapper").Panel("ctl00_sectionHeader").Panel(0).Panel("ctl00_UcHeader_sectionLogin").Panel("ctl00_UcHeader_UcHeaderLogin_divLogged").Panel(0).TextNode("ctl00_UcHeader_UcHeaderLogin_lbLoggedIn").textContent != "Currently logged in")



........

}


The idea is that if the login is not successful, retry the login. However, if the first login attempt has failed and the second succeeded,   I still get an error for the while part. I've tried modifying it using WaitPage or WaitProcess but no luck. 


Please assist.


Thank you, 


Andrei


2 Replies

  • Hi Andrei,


    I guess, the problem is that some of the objects mentioned in the while(...) statement cannot be found if the login operation fails, and therefore, the appropriate message is posted to the test log. If so, I recommend that you use one of the Wait* methods to make TestComplete wait until the problematic object appears and then check whether the returned object exists - this will allow you to avoid the message. Please see the "Additional Methods Used to Obtain Web Pages Elements" section of the "Working With Web Page Elements" help topic ( http://www.automatedqa.com/support/viewarticle.aspx?aid=6318 ) for more information.


  • Hi, 


    thank you, that worked. Using the WaitTable  method I managed to make TC wait for the table that was not found.


    Thanks again, 


    Andrei