6 Answers, 1 is accepted
0
Nitin
Top achievements
Rank 1
answered on 02 Feb 2012, 06:52 AM
Hi lucia
there is a workaround you can try
before performing any Event on button (like click),
you can use the Code as:-
button.Wait.ForExists(4000); or button.Wait.ForVisible(4000);
4000 is time in ms, you can increase its up to you
then perform your event
Thanks
Nitin
there is a workaround you can try
before performing any Event on button (like click),
you can use the Code as:-
button.Wait.ForExists(4000); or button.Wait.ForVisible(4000);
4000 is time in ms, you can increase its up to you
then perform your event
Thanks
Nitin
0
Hello Lucia,
Be aware of the difference between HtmlButton and HtmlInputButton as outlined here.
The procedure is nearly the same for a Silverlight button:
@Nitin: I awarded you Telerik points for assisting another customer.
Kind regards,
Anthony
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Nitin is correct; those are two good implementations to use. There is also a way to specifically verify if the button is enabled:
HtmlButton b = Find.ById<HtmlButton>(
"b1"
);
Assert.IsTrue(b.IsEnabled);
Be aware of the difference between HtmlButton and HtmlInputButton as outlined here.
The procedure is nearly the same for a Silverlight button:
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
Button b = app.Find.ByAutomationId<Button>(
"CancelButton"
);
Assert.IsTrue(b.IsEnabled);
@Nitin: I awarded you Telerik points for assisting another customer.
Kind regards,
Anthony
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
lucia
Top achievements
Rank 1
answered on 06 Feb 2012, 07:47 AM
Hi Anthony & Nitin
Thanks for your help!!
But the workaround you recommended cannot yet resolve my issue because actually the silverlight button always exists and is visible on the page. Just when the page is loaded, the button is disabled and after waits for a while, the button becomes enabled. So I want to use wait.for to wait some time till the button is enabled and then execute the left codes.
Any other methods to implement my requirements?
Thanks a lot!!
Thanks for your help!!
But the workaround you recommended cannot yet resolve my issue because actually the silverlight button always exists and is visible on the page. Just when the page is loaded, the button is disabled and after waits for a while, the button becomes enabled. So I want to use wait.for to wait some time till the button is enabled and then execute the left codes.
Any other methods to implement my requirements?
Thanks a lot!!
0
Nitin
Top achievements
Rank 1
answered on 06 Feb 2012, 08:27 AM
Hi Lucia
How much time it take to enable (any idea about how many millisecs)
if yes, then you can use
System.threading.thread.sleep(int ms);
or you can check the Button Property if IsEnabled then Click that button using if condition
if (SilverlightApp.button.isEnabled==true)
{
Click on that button
}
Hope this Helps
Thanks
How much time it take to enable (any idea about how many millisecs)
if yes, then you can use
System.threading.thread.sleep(int ms);
or you can check the Button Property if IsEnabled then Click that button using if condition
if (SilverlightApp.button.isEnabled==true)
{
Click on that button
}
Hope this Helps
Thanks
0
lucia
Top achievements
Rank 1
answered on 06 Feb 2012, 10:10 AM
HI Nitin
For now, I just use System.threading.thread.sleep(int ms) to walkaround the issue instead of wait.for . But I still want to know whether I can use wait.for to implement too because if I use the sleep, the time to wait for is a fixed value, and so although the button is enabled before this time, it still waits for the time to execute the next code. Besides, the time to wait is different during every page loading. If I can use wait.for, then the time waitting for the button's being enabled is dynamic, and no need to wait for the fixed value. So I think this will be more efficient.
Thanks!!
Lucia
For now, I just use System.threading.thread.sleep(int ms) to walkaround the issue instead of wait.for . But I still want to know whether I can use wait.for to implement too because if I use the sleep, the time to wait for is a fixed value, and so although the button is enabled before this time, it still waits for the time to execute the next code. Besides, the time to wait is different during every page loading. If I can use wait.for, then the time waitting for the button's being enabled is dynamic, and no need to wait for the fixed value. So I think this will be more efficient.
Thanks!!
Lucia
0
Hello Lucia,
Use the following code to wait for a Silverlight button to be enabled:
Greetings,
Anthony
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Use the following code to wait for a Silverlight button to be enabled:
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
Button b = app.Find.ByAutomationId<Button>(
"CancelButton"
);
Wait.For<ArtOfTest.WebAii.Silverlight.UI.Button>((a) => ((a.IsEnabled ==
null
) ? (
true
==
null
) : a.IsEnabled.Equals(
true
)), b,
false
, 15000);
Greetings,
Anthony
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.