Unable to uncheck checkbox in Webdocument

Bug reports.
sunitha
Posts: 24
Joined: Thu May 14, 2009 2:06 pm

Unable to uncheck checkbox in Webdocument

Post by sunitha » Mon May 25, 2009 2:23 pm

I am able to check the checkbox in web document but unable to uncheck the same checkbox.

Here is the code used:

repository.webdocument.checkboxmin.Checked = false.ToString(); :)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon May 25, 2009 3:05 pm

The "checked" property in the InputTag Adapter is directly mapped to the HTML "checked" attribute. So to uncheck the checkbox just set the "Checked" property to an empty string:

repository.webdocument.checkboxmin.Checked = "";

Because this is a bit counter-intuitive we will probably do something about that in a future release .. :)

Michael
Ranorex Team

sunitha
Posts: 24
Joined: Thu May 14, 2009 2:06 pm

Unable to uncheck checkbox in Webdocument

Post by sunitha » Tue May 26, 2009 5:40 am

Even repository.webdocument.checkboxmin.Checked = ""; is not working

Any other solutions for this????

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue May 26, 2009 9:40 am

Does the HTML source for your checkbox look like this ?

<input type="checkbox" name="testcheckbox" id="testcheckbox"/>

With this HTML input tag, the solution above works perfectly for me.

Michael
Ranorex Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Tue May 26, 2009 4:37 pm

If it is OK for you to use a method that uses PerformClick then you can try this method below:

Code: Select all

if (SelectCheckBox == true)
{
	Report.Info("Selecting checkbox: " + CheckBoxName);
	if (DOMCheckBox.Checked.ToUpper() != "TRUE")
	{
		Report.Debug("  Selected checkbox: " + CheckBoxName);
		DOMCheckBox.EnsureVisible();
		DOMCheckBox.Focus();
		Thread.Sleep(1000);
		DOMCheckBox.PerformClick();
	}
	else
	{
		Report.Info("  " + CheckBoxName + " was already Selected");
	}
}
else
{
	Report.Info("DE-Selecting checkbox: " + CheckBoxName);
	if (DOMCheckBox.Checked.ToUpper() == "TRUE")
	{
		Report.Debug("  DE-Selected checkbox: " + CheckBoxName);
		DOMCheckBox.EnsureVisible();
		DOMCheckBox.Focus();
		Thread.Sleep(1000);
		DOMCheckBox.PerformClick();
	}
	else
	{
		Report.Info("  " + CheckBoxName + " was already DE-Selected");
	}
}

sunitha
Posts: 24
Joined: Thu May 14, 2009 2:06 pm

Unable to uncheck checkbox in Webdocument

Post by sunitha » Wed May 27, 2009 7:37 am

Html source for my checkbox looks like this.

<INPUT id=idchk_10011 type=checkbox CHECKED>.

repository.webdocument.checkboxmin.Checked = ""; isnt working. I am unable to uncheck the checkbox.

If i uncheck manually and try to check the checkbox it is working fine.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed May 27, 2009 8:47 am

Sorry, I cannot reproduce your problem.
The workaround Ciege suggested should work fine.

If you are using PerformClick() you *should* be able to skip
the EnsureVisible(), Focus() and Sleep() because it actually doesnt use the mouse.

@Ciege: you might want to use Delay.Seconds(1) or Delay.Ms(1000) instead of Thread.Sleep(). You can then use Delay.ScaleFactor to globally scale all your delays if you feel the need for it... :D

Michael
Ranorex Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Wed May 27, 2009 4:19 pm

Support Team wrote: @Ciege: you might want to use Delay.Seconds(1) or Delay.Ms(1000) instead of Thread.Sleep(). You can then use Delay.ScaleFactor to globally scale all your delays if you feel the need for it... :D

Michael
Ranorex Team
Thanks for the tip. Is there a specific reason why I would choose Delay over Thread.Sleep? Or is that just "better" code?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Thu May 28, 2009 1:08 pm

Well, if you use Delay() you can also do something like this:
Delay.Duration("2m")
and if you set the Delay.SpeedFactor you can globally scale all delays, so for example if you use Delay.Seconds(10) in some locations, and you set SpeedFactor = 2 then all delays are reduced to 5 seconds.
(Edit: the example described it backwards)

It's also used by the generated recorder code, because of the speed factor and better readibility. But its definitely no problem if you use Thread.Sleep() instead.

Michael
Ranorex Team
Last edited by Support Team on Sat May 30, 2009 5:09 pm, edited 1 time in total.

sunitha
Posts: 24
Joined: Thu May 14, 2009 2:06 pm

Unable to uncheck checkbox in Webdocument

Post by sunitha » Fri May 29, 2009 1:07 pm

Thanks for your solutions , but i have tried with these. None of them worked
Any more solutions left. :)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Jun 02, 2009 3:32 pm

Did you try a "plain" automated mouse click, or is this not possible in your scenario ?

Michael
Ranorex Team