Page 1 of 1

Test skips the step

Posted: Tue Nov 26, 2013 11:22 pm
by ngrishakin
I have a simple function that I call from my test. wDoc is a WebDocument passed as a parameter to the class.
The following code pushes "Add New Client" button, types ClientName in a text box and pushes Save button.
For some reason at runtime Save Button is being missed and test fails. Looks like it trying to press Save before it finishes typing all chars into ClientName_EditBox and Save button is disabled for some time. I wonder why it even jumps to next line before finishing typing client name? "ClientName_EditBox.PressKeys(ClientName);".
Thanks,
Nikolay


public void Add_New_Client(string clientName)
{
WebElement AddClient = wDoc.FindSingle("/dom[@caption='Clients']//div[#'middle-container']/div[2]//a[@innertext='Add Client']");
AddClient.Click(); //Press AddClient button
wDoc.WaitForDocumentLoaded();
WebElement ClientName_EditBox = wDoc.FindSingle("/dom[@caption='Clients']//input[#'Name']");
ClientName_EditBox.PressKeys(ClientName);

WebElement Save_and_Close = wDoc.FindSingle("/dom[@caption='Clients']//a[#'Save']");
Save_and_Close.Click();
wDoc.WaitForDocumentLoaded();
}

Re: Test skips the step

Posted: Tue Nov 26, 2013 11:53 pm
by ngrishakin
I found why. I have two buttons "Save and Close" and "Save and Add New". Both have the same ATag "Save" and same RxPath. So it hits "Save and add new" instead "Save and Close" that I really want. Inner text is different on buttons. Anyone can suggest how can I add or change manually RxPath for these buttons.
Thanks a lot,
Nikolay

Re: Test skips the step

Posted: Wed Nov 27, 2013 6:07 pm
by Support Team
Hello Nikolay,

You could add the innertext attribute to the RxPath.
Please try it out with the following path:

Code: Select all

/dom[@caption='Clients']//a[@id='Save' and @innertext='<InnerText>']
Please simply replace the <InnerText> with your value.

Regards,
Markus (T)

Re: Test skips the step

Posted: Wed Nov 27, 2013 6:30 pm
by ngrishakin
I change it to
WebElement Save_and_Close = wDoc.FindSingle("/dom[@caption='Clients']//a[@innertext='Save and Close']");
Save_and_Close.Click();

But it does not return exception that element not found but does not click on it as well

Re: Test skips the step

Posted: Wed Nov 27, 2013 6:35 pm
by ngrishakin
The same thing if I use both elements
wDoc.FindSingle("/dom[@caption='Clients']//a[@id='Save' and @innertext='Save and Close']");

Don't know why it does not return exception "Element not found". It sees it but fails to click

Re: Test skips the step

Posted: Wed Nov 27, 2013 6:46 pm
by ngrishakin
I found the work around by executing java script directly:
wDoc.ExecuteScript("UpdateClient(2);");
But still don't understand why other methods don't work

Re: Test skips the step

Posted: Thu Nov 28, 2013 3:50 pm
by Support Team
Hello ngridshakin,

In general, it should work to click on this button.
It might be that the web document is not updated.
Please try out the following method:
WebElement Save_and_Close = "/dom[@caption='Clients']//a[@innertext='Save and Close']");
Save_and_Close.Click();
Please let me know if it worked.

Regards,
Markus (T)