CheckBox Issues

Ask general questions here.
MdeVolder
Posts: 3
Joined: Tue Apr 02, 2019 11:22 am

CheckBox Issues

Post by MdeVolder » Tue Apr 02, 2019 11:28 am

Hi all,

I have been browsing the forum for a while and puzzling to fix my issue but so far I am struggling.
I want to automate a function we have on our website, but before that I want to ensure certain facilities that the website offers are turned on or off.

The snapshot is added as an example.
I made a testbuild that I had working on Friday but now it gives a build error
(The recording 'CheckboxCheck.rxrec' has build errors)

And when I altered it to a different checkbox in a new test I just couldnt get it to work at all. (but then the checkbox stated it was not in a .wrapper but in a .someDivTag)

Does anybody know anything that can help me out here?
{

public partial class TestCheckBoxes
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
}

public void Mouse_Validation(RepoItemInfo inputtagInfo)
{
//create the checkbox
Ranorex.InputTag cusChkbox1 = repo.MGnZorgverlenersportaal.Wrapper.MobileApp;

//if checkbox is unchecked, click on it, else double click
if (cusChkbox1.Checked=="True")
{
cusChkbox1.Click();
}
else {
cusChkbox1.DoubleClick();
}

}
Attachments
All Facility On.rxsnp
(127.97 KiB) Downloaded 8 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4924
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: CheckBox Issues

Post by odklizec » Tue Apr 02, 2019 2:43 pm

Hi,

Could you please post a full xpath for given checkbox element, as stored in repo? The code you are using looks OK. But it's hard to tell what's wrong, without knowing the xpath. Also, it would be good to know Ranorex version. Are you using the latest one (8.3.3 or 9.0)?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

MdeVolder
Posts: 3
Joined: Tue Apr 02, 2019 11:22 am

Re: CheckBox Issues

Post by MdeVolder » Thu Apr 04, 2019 8:59 am

It's Ranorex version 8.3.0

I am not familiar with Xpaths, but I found an introductory video on that on this website so I will look into that and hopefully be able to give an answer to that.

MdeVolder
Posts: 3
Joined: Tue Apr 02, 2019 11:22 am

Re: CheckBox Issues

Post by MdeVolder » Thu Apr 04, 2019 1:19 pm

is this the xPath?
/dom[@caption='MGnZorgverlenersportaal']//div[#'app']/div/div[1]/div/div[2]/div/div[2]/div/div/div[2]/div[2]/?/?/div/label[1]/input[@title='mobileApp']

McTurtle
Posts: 255
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: CheckBox Issues

Post by McTurtle » Thu Apr 11, 2019 12:03 pm

Hello MdeVolder,

The Caption attribute in your snapshot is "MGn Zorgverlenersportaal" and in your RanoreXPath it is "MGnZorgverlenersportaal". There is a space in your snapshot. If your RanoreXPath in the repository does not have the space, then the element won't be found.

Also, your code says if checkbox is checked, then click, else double-click. This is exactly the opposite of what you are writing in the comment of the code.

Does this help?

Regards,
McTurtle

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4924
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: CheckBox Issues

Post by odklizec » Thu Apr 11, 2019 12:32 pm

Hi,

Aside to what McTurtle suggested, I would also suggest to simplify the xpath, to make it more stable. Generally speaking, xpaths with a lot of elements end especially elements indexes (which tends to change), are too fragile and easy to fail. Hence I would suggest to use something like this:
/dom[@caption='MGn Zorgverlenersportaal']/body//div[@class='container']//div[@class='main-content']//div[@class='page__body']//div/label[@class='checkbox-container']/input[@title='mobileApp']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration