Test skips the step

Class library usage, coding and language questions.
ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Test skips the step

Post by ngrishakin » Tue Nov 26, 2013 11:22 pm

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();
}

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Test skips the step

Post by ngrishakin » Tue Nov 26, 2013 11:53 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Test skips the step

Post by Support Team » Wed Nov 27, 2013 6:07 pm

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)
.
Image

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Test skips the step

Post by ngrishakin » Wed Nov 27, 2013 6:30 pm

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

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Test skips the step

Post by ngrishakin » Wed Nov 27, 2013 6:35 pm

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

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Test skips the step

Post by ngrishakin » Wed Nov 27, 2013 6:46 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Test skips the step

Post by Support Team » Thu Nov 28, 2013 3:50 pm

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)
.
Image