Example xaml code on the page which causes StackOverflowException.
If remove MyProperty="{Binding ElementName=SourceFlyout}" from second element,
it's ok. MyProperty is an attached property. AdvancedBehavior is the simplest behavior class and the bug is easily reproduced.
MyProperty is an empty attached or dependency property with no logic inside. What happens?
<ListPickerFlyout x:Name="SourceFlyout">
<helpers:XamlExtention.Behaviors>
<helpers:BehaviorCollection>
<behaviors:AdvancedBehavior MyProperty="{Binding ElementName=DestinationFlyout}" />
</helpers:BehaviorCollection>
</helpers:XamlExtention.Behaviors>
</ListPickerFlyout>
<ListPickerFlyout x:Name="DestinationFlyout">
<helpers:XamlExtention.Behaviors>
<helpers:BehaviorCollection>
<behaviors:AdvancedBehavior MyProperty="{Binding ElementName=SourceFlyout}" />
</helpers:BehaviorCollection>
</helpers:XamlExtention.Behaviors>
</ListPickerFlyout>
The behavior AdvancedBehavior is not expecting to be bound to a SourceFlyout via MyProperty, you need to determine the actual data needed for MyProperty to work properly.
Related
I am having the following issue in my Capybara environment:
I need to search for an element. This element contains an attribute, which is unique. The attribute is changed asynchronously.
I need the content of this attribute, but when I just search for the attribute I am getting a nil.
I could wait until the attribute has the property, but since this is Capybaras job, I thought there might be a possible selector, which can search for something like:
find('button[uniqueattribute] != nil')
Any ideas how to do this?
Thanks already!
If the attribute is being added to the button element (didn't have the attribute originally) then you can just do
find('button[attribute_name]')
which will wait (up to Capybara.max_default_wait_time seconds for a button element with that attribute to be on the page - https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors. To wait and then get the contents/value of that attribute you could do
find('button[attribute_name]')['attribute_name']
If you just want to wait until the attribute is either not there or not blank then you can do
find('button:not([attribute_name=""])')
If you need to ensure the attribute is there, but isn't blank it would be
find('button[attribute_name]:not([attribute_name=""])')
I found a possible solution:
You can check the length of an element by Xpath (which is awesome) with string-length.
So in my case the solution was:
find(:xpath, ".//button[#unique_attribute_name[string-length() != 0]]")
Now Capybara waits until the attribute has a value. If there are more pretty solutions, just tell me.
in my page object I have simple method
def clickSomething(byName) {
$("a.name", text: contains(byName)).click()
}
and during execution it does not find required element and goes further.
it happens because, according to documentation, $() returns EmptyNavigator if element not found.
I want for test to fail with some kind of "ElementNotFoundException" or "NullPointerException" on trying to make click on null element.
I also do not want to add additional checks for returned element (because I would need to add that for every element identification).
Is there an elegant workaround for that ?
e.g. for elements declared within "content" there is performed such a check. But what is the best practice for elements found outside content block ?
The issue that you've encountered which is click() not throwing an error when called on en empty navigator has been fixed recently and will be released in the next version of Geb.
If you need to get an error when a selector results in an empty navigator then you can either:
wrap your selector in a content definition with the required template option set to true which is the default
call verifyNotEmpty() on your navigator
I'm trying to check if a value is contained in the innertext of a webelement but I'm having a little problem: frames seem to change at every refresh of the pages.
These are the steps I've recorded:
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebEdit("pdrBean.pdrPod").Set parameter("POD")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebButton("Cerca").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_2").Image("show_files").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_6").Image("Lente").Click
cctype = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down").GetROProperty("innertext")<br>
DataAct = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down_2").GetROProperty("innertext")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click
The frames "dme2_appl6" and "dme2_appl7" changes at every refresh of the two pages.
The question is simple: how can I rewrite these two actions to make them universal?
I've tried to do something like:
Set objFrame = Frame("title:=dme2_appl_.")
and then
Browser("SystemPage").Page("SystemP").objFrame.Image("Lente").Click
But QTP gives me an error in return: "property or method not supported by the object"
Please try using the below code
Browser("SystemPage").Page("SystemP").Image("Lente").Click
Avoid using the "Frame" and if you really want to use it, put regex for name property of Frame.
Go to Object Properties--> Click on the Frame object --> Mandatory Properties--> Change name property as
like iFrame_213123123 to i.*
Hope this will solve your problem.
I don't think you can use a frame object that way. When you write Page().Frame() UFT sets the frame's parent in different way than if you first create the Frame.
Think of Frame() as a function that behaves differently when called on a Page or as a free function.
Try:
Browser("SystemPage").Page("SystemP").Frame("title:=dme2_appl_.")
I have a couple of MovieClips in swf files loaded with Loader.loadBytes. They are 10-th version, as3-enabled and have scale9Grid defined (I can see the tag DefineScaleGrid in them with SWiX). But when loaded, loader.content has scale9Grid == null (maybe it is normal?) and scaling is not 9-slice. I can't even set scale9Grid myself - any attempt is met with exception "One of the parameters is invalid". How to make 9-slice grid work?
I finally found this article to explain it all. So, in short, scale9Grid works only on DisplayObjects without children. I dug down to Shape in my clip and managed to set that grid.
I'm trying to add Validation to a Silverlight 3.0 TextBox but cannot seem to find and example which is complete, and not missing functionality that makes it work, I have this property:
''' <summary>Tag</summary>
''' <value>String</value>
''' <returns>String</returns>
''' <remarks>Contains Validation</remarks>
Public Property Tag() As String
Get
Return _Tag
End Get
Set(ByVal Value As String)
If Value.Length < 1 Or Value.Length > 20 Then
Throw New Exception("Must be between 1 and 20 characters")
End If
_Tag = Value
NotifyPropertyChanged("Tag")
End Set
End Property
This is in a class which implements the INotifyPropertyChanged class, I have this textbox:
<TextBox Name="txtTag" Text="{Binding Path=Tag, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"/>
In my XAML, what do I need to do to have this use Validation correctly - that is show the "red" tooltip to show the error message, my code just throws the exception, and does not display the message at or work correctly.
I have found examples online, but all seem to miss out a critical piece of functionality that makes this work - what is the reason for this? I just want to do simple validation in Silverlight, I know it is possible so if anyone knows an end-to-end solution to make this work then please post it here.
This is an open-source project so I won't be keeping the solution to myself - so it may help others as this is quite a useful feature - if not poorly explained for me to get it to work.
Edit
Just though I would add that if possible can the Error condition of a Textbox be invoked without using an exception - i.e I do my own validation and then call the error state on the TextBox and show the custom error message, this would be an acceptable alternative.
I have the Tag property in a Class, I'm guessing when the exception is thrown it cannot be caught by the TextBox as it is not in the MainPage class, but there is so little documentation, a couple of good examples with no code I'm not sure how this is supposed to work.
Hopefully there is a solution that does not involve re-implementing the error state with coloured borders and custom tooltips, as the functionality is there - I just need to use it!
Your code looks fine. You can add a <ValidationSummary/> to the panel containing the TextBox to see the validation errors. You can also subscribe to the TextBox.BindingValidationError event to see when validation errors occur as in the data-binding. If you debug your code you should be able to first see the exception being thrown and then the event being raised.
Unfortunately you cannot "manually" add validation errors to the TextBox. To get a validation error you will have to throw an exception in the a data-bound property like you do. If you want really fine-grained control of when the validation error occurs you can manually update the binding expression.
Instead of performing your validation in code you can use the attributes in namepace System.ComponentModel.DataAnnotations. For instance, to validate on string length you can use the StringLength attribute:
<StringLength(20, MinimumLength:=1>
Public Property Tag() As String
Get
....
Check out this blog on Silverlight Data Binding/Validation:
Data Binding - Data Validation
...it looks like you're missing the Error Event Handler (what does the work when the Exception is thrown). Check the link to see what I'm talking about.