cancel
Showing results for 
Search instead for 
Did you mean: 

Missing checkbox

SOLVED
New Contributor

Missing checkbox

Hi all,

 

I'm testing a webpage in Chrome. I recorded the flow, but when I played back, TestComplete could not find the checkbox. I tried to select the object with drag the target and point and fix tools but they not marked the checkbox exactly (just the whole field with a name).

I find the checkbox in html and saw the xpath but I dont know how to put manually into the test. 

If you have any idea to fix my first test, please contact me 🙂 Thanks!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Missing checkbox

Hi,

 

Thank you for the screenshot. What is reported to test log if you execute this test?

From what I see, I can make these notes:

1. The operation (Call Object Method) where you are searching for the web element using .FindChildByXPath() method returns the object been found. In order to use this object later, you must create keyword test variable and assign this variable a value returned by .FindChildByXPath(). Use the Set Variable Value operation with the Last Operation Result option value for the Mode parameter.

2. Sample code snippet that I provided previously assumed that the tested web page is referenced via the page variable, but in your keyword test the tested web page is referenced as pageIts20. So the code must be adjusted correspondingly.

3. Use either approach with .FindChildByXPath() or the code that was provided as the alternative. Alternative code may be used as is (with corrected reference to page). If you decide to use .FindChildByXPath(), then you should assign the result of the search to variable (as mentioned in point 1) and then use this variable to call method .click() (note small first 'c') of the found object.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

7 REPLIES 7
Community Hero

Re: Missing checkbox

Hi,

 

Can you post here a screenshot and the html markup of the problematic check-box and its parent element?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Contributor

Re: Missing checkbox

Hi Alex,

is that ok? 

Thanks 

 

Community Hero

Re: Missing checkbox

Hi,

 

is that ok?

Yes, it is. 🙂

Actually, this is what I expected to see.

As you can see from the markup, there is no actual check-box there, but just a span element styled to look like check-box, with no text and presentation role. Such elements are excluded from the objects hierarchy in TestComplete as documented here: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/object-identification/tree-m....

Unless you can solve this problem with your Development, the following workaround can be used:

-- Find the element that works as a label for this pseudo check-box ('Megtekintes' as per your screenshot);

-- Try to click, say, 5 pixels to the left from label's left border

Pseudocode:

var label = page.FindChild('value', 'Megtekintes', 50);

label.Click(label.Left - 5, label.Top + label.Height / 2);

 

OR

-- use the .FindChildByXPath() method to find the span element itself.

Note, that in this case, as this span element is absent in TestComplete's Objects Tree, as a search result you will get not TestComplete's object, but native DOM one. In order to click this object, native .click() method must be used (note small 'c' at the beginning):

var checkbox = page.FindChildByXPath(<XPath>);

checkbox.click();

 

It is expected that the value of some attribute of the span element will change after the click.

You may use the native .getAttribute() method (if I remember it correctly) to get the value of this property and determine the state of this pseudo check-box (checked or unchecked).

 

Hope this will help.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Contributor

Re: Missing checkbox

Hi,

 

sorry about the stupid questions. 

 

I recorded again the test and tried to click like you said. Where can I use the pseudo that you wrote?

 

I set the operation FindChildByXPath with a Megtekintes value (SearchInFrames 1). 

I send you a picture about Object Browser.

 

Can you write step by step how can I set the missing parts? 

 

Thaks a lot! 

Community Hero

Re: Missing checkbox

Hi,

 

Where can I use the pseudo that you wrote?

The suggested code should be inserted where the recorded click is done. (Post recorded script or screenshot of the keyword test if you like me to point you exact place.)

 

Can you write step by step how can I set the missing parts?

Assuming screenshots that you already posted (and JScript language), I would start with this:

-- Code snippet:

var cbox = page.FindChildByXPath('//SPAN[contains(@id, '-checkboxEl')];

if (cbox != null)

  cbox.click();

else

  Log.Error('check-box for Megtekintes label was not found');

 

-- Paste this code snippet instead the line where the click on check-box was recorded and try to execute.

 

 

P.S. Alternative code snippet:

var cboxLabel = page.FindChild(['ObjectIdentifier', 'contentText'], ['appcheckcolumn_textInnerEl', 'Megtekin*'], 100);

if (cboxLabel.Exists)

  cboxLabel.Click(cboxLabel.Left - 5, cboxLabel.Top + cboxLabel.Height / 2);

else

  Log.Error('Megtekintes label for check-box was not found');

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Contributor

Re: Missing checkbox

Hi Alex,

 

i send you a new pic about a test. 

 

Thanks!

Community Hero

Re: Missing checkbox

Hi,

 

Thank you for the screenshot. What is reported to test log if you execute this test?

From what I see, I can make these notes:

1. The operation (Call Object Method) where you are searching for the web element using .FindChildByXPath() method returns the object been found. In order to use this object later, you must create keyword test variable and assign this variable a value returned by .FindChildByXPath(). Use the Set Variable Value operation with the Last Operation Result option value for the Mode parameter.

2. Sample code snippet that I provided previously assumed that the tested web page is referenced via the page variable, but in your keyword test the tested web page is referenced as pageIts20. So the code must be adjusted correspondingly.

3. Use either approach with .FindChildByXPath() or the code that was provided as the alternative. Alternative code may be used as is (with corrected reference to page). If you decide to use .FindChildByXPath(), then you should assign the result of the search to variable (as mentioned in point 1) and then use this variable to call method .click() (note small first 'c') of the found object.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors