Cannot find the specific element with Find class in WatIN - watin

I am trying to automate rest client but when I try to enter a value in the URL text-box it does not find the object by id and even by name
What I actually did was Find.ById and Find.ByName but it does not seem to find the element.

In order to do it, you need to override the existing functionality. Below is the code to get the textfield of type 'URL'.
[ElementTag("input", InputType = "url", Index = 5)]
public class CustomTextField : Element<CustomTextField>
{
public CustomTextField(DomContainer domContainer, INativeElement element) : base(domContainer, element) { }
public CustomTextField(DomContainer domContainer, ElementFinder finder) : base(domContainer, finder) { }
}

Related

Acumatica - PrimaryView property doesn't populate on page datasource control

I am following instructions to add a Customized page but cannot get any values to populate the PrimaryView property.
I've followed these steps a few times along with Clean/Build project and closing Visual Studio, but nothing is working. I'm just missing something.
In this order:
1- Created new table in Sql called INMerchandiseGroup with similar makeup as Country table.
2- Defined my graph by creating a PXGraph called MerchandiseGroupMaint.
3- Created axpx page called IN201000 using a ListView control.
4- Bind graph to aspx page by setting datasource TypeName to graph.
5- Generated Data Class through aspx page datasource control, loading new table INMerchandiseGroup, selecting GroupCD and description; set GroupCD IsKey = true and removed string defaults (""), saved and rebuild
6- Added PXSelect actions (alone and with PXDelete, PXCancel) in graph.
7- !!!Problem!!! I go to Properties for datasource to set PrimaryView and nothing is there to select.
Graph:
public class MerchandiseGroupMaint : PXGraph<MerchandiseGroupMaint>
{
PXCancel<INMerchGroup> Cancel;
PXSave<INMerchGroup> Save;
PXSelect<INMerchGroup> MerchandiseGroups;
}
Dataclass:
[System.SerializableAttribute()]
public class INMerchGroup : PX.Data.IBqlTable
{
#region GroupCD
public abstract class groupCD : PX.Data.IBqlField
{
}
protected string _GroupCD;
[PXDBString(10, IsUnicode = true, IsKey = true)]
[PXDefault]
[PXUIField(DisplayName = "Group ID")]
public virtual string GroupCD
{
get
{
return this._GroupCD;
}
set
{
this._GroupCD = value;
}
}
#endregion
#region Description
public abstract class description : PX.Data.IBqlField
{
}
protected string _Description;
[PXDBString(256, IsUnicode = true)]
[PXDefault]
[PXUIField(DisplayName = "Description")]
public virtual string Description
{
get
{
return this._Description;
}
set
{
this._Description = value;
}
}
#endregion
I don't get any error messages...if i manually add the PrimaryView to aspx Source code I get an error that view isn't found.
What am I not doing?
A new screen can be configured this way,look maybe missed something
To Create a Custom Form Template
The problem was so silly, I don't know how i didn't see it. I was missing the "public" access modifier.
public class MerchandiseGroupMaint : PXGraph<MerchandiseGroupMaint>
{
public PXCancel<INMerchGroup> Cancel;
public PXSave<INMerchGroup> Save;
public PXSelect<INMerchGroup> MerchandiseGroups;
}

xamarin: binding object and object parent to property change

I have a model "optionModel" with "data" member as a list of "options". Option has title and status members:
class optionModel
{
...
public List<option> data {get; private set;}
}
class option
{
...
public String title{get;set}
public bool status {get;set}
}
My view for the model is a grid, which is populating like this:
optionModel _m = new optionModel();
Grid g = new Grid();
foreach (option op in _m.data)
{
..
TextSwitch tc = new TextSwitch(); // view class
tc.BindingContext = op;
tc.SetBinding(TextSwitch.IsToggledProperty, "status");
g.Children.Add(tc, 0, iRow);
..
}
Everything works as expected. "status" property of the "option" is updated, I am happy.
My question is: In addition to "option" I also want "optionModel" to be notified when any of the "option" change their status. One immediate solution is
to construct the "option" to have pointer to the optionModel and notify optionModel it within "status" set method of "option".
But perhaps there is a way to do it via Xamarin binding mechanism without introducing optionModel as a member of "option"?
Thanks!

What is the proper way to have a ListView show a LINQ query and update dynamically?

I'm new to Xamarin and C#, so apologies in advance for any mistakes I make.
In my app, I have a list of plants. When a plant is selected, I have a detail view of info about the plant. In the detail view, I have a button that adds or removes the plant from a shopping list.
To implement this, I have a class named MyPlant, with a field called InCart, and a method ToggleInCart that the button calls.
(note that I didn't paste in some code to simplify this question as much as possible)
public class MyPlant : INotifyPropertyChanged
{
string name;
bool inCart;
...
public bool InCart
{
set
{
if (inCart != value)
{
inCart = value;
OnPropertyChanged("InCart");
}
}
get { return inCart; }
}
public ICommand ToggleCartStatus
{
get
{
if (_toggleCartStatus == null)
{
_toggleCartStatus = new Command(() => InCart = !InCart);
}
return _toggleCartStatus;
}
I have another class called PlantList, which has a method PlantsInCart that uses LINQ to return an ObservableCollection of MyPlant where InCart is true.
public class PlantList : INotifyPropertyChanged
{
public ObservableCollection PlantsInCart
{
private set { }
get
{
ObservableCollection list = new ObservableCollection(myPlants.Where(i => i.InCart));
return list;
}
}
In my XAML, I have a ListView bound to PlantsInCart.
Everything works as I want EXCEPT when I remove the selected plant, the list doesn't update to show the plant is missing even though the data underneath it is correctly updated. If I refresh the list by going to a different page and coming back, then the list shows the right plants.
I suspect this doesn't work because the change in the InCart field isn't bubbling up high enough to that the ListView hears that it is supposed to update.
Can anybody advise me on the proper way to implement this kind of feature? In other words, how should you implement a scenario where you have a list that should update when a property of an item in the list changes?

How do I remove format from Linq property?

I´m building a Windows Forms aplication using LINQ to SQL. I´m using the auto generated code from the
dbml file.
Visual studio generated this code for the CNPJ property from my table:
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CNPJ", DbType="VarChar(20) NOT NULL", CanBeNull=false)]
public string CNPJ
{
get
{
return this._CNPJ;
}
set
{
if ((this._CNPJ != value))
{
this.OnCNPJChanging(value);
this.SendPropertyChanging();
this._CNPJ = value;
this.SendPropertyChanged("CNPJ");
this.OnCNPJChanged();
}
}
}
and what I wanted is this:
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CNPJ", DbType="VarChar(20) NOT NULL", CanBeNull=false)]
public string CNPJ
{
get
{
return APPLY_FORMAT(this._CNPJ);//Changed here
}
set
{
if ((this._CNPJ != value))
{
this.OnCNPJChanging(value);
this.SendPropertyChanging();
this._CNPJ = REMOVE_FORMAT(value); /// Changed here
this.SendPropertyChanged("CNPJ");
this.OnCNPJChanged();
}
}
}
But I will lose this changes when the code is re-generated.
Question is: what is the right way to accomplish this behavior (inherit and override, capture change event, other ) ?
if you´re curious, CNPJ is the brazilin business identification number, provided by the government.
Rather than trying to change the existing property, create a new property.
public partial class YourClass
{
public string FORMATTED_CNPJ
{
get
{
return APPLY_FORMAT(this._CNPJ);
}
set
{
this.CNPJ = REMOVE_FORMAT(value);
}
}
}
If you don't want anyone to access the underlying CNPJ property you can set it to private in the designer (the access modifier combobox in the column properties window). You can even rename that property to _CNPJ, make it private, and then name your 'wrapper' property above CNPJ if you want to avoid any breaking changes.
LINQ to SQL creates the classes as partial classes. You can create another partial class in a different file but with the same class name and then you can change the behaviour.
public partial class YourClass
{
partial void OnCNPJChanged()
{
this._CNPJ = REMOVE_FORMAT(value);
}
}
See here for more information.

Can I associate an image with a class and load this image without creating an instance of the class?

Long time lurker, first time poster here.
My question is:
Using C# 2.0, is there a way to associate am image with a class/type such that I don't have to create an instance of the class just to get the image object from that class?
What I am trying to do is scan all the .dlls in my application and construct a list of classes and corresponding attributes. I have this working great, and now I want to somehow associate an image with each class so that I can display a list of classes and have a unique image for each.
I've tried searching SO and the internet for an answer, but can't find anything definite. Any help would be greatly appreciated.
Thanks,
Kyle
You could create an ImageAttribute.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
class ImageAttribute : Attribute
{
private string ImagePath { get; set; }
public ImageAttribute(string imagePath)
{
ImagePath = imagePath;
}
public Bitmap Image
{
get { return new Bitmap(ImagePath); }
}
}
Or database id, just some way to identify an image.
Figured out how to do it using ideas here and there.
Mark the image as an EmbeddedResource.
Create an attribute for specifying the image name.
Once the image name attribute is read, use the following to locate the image resource inside the assembly where the class was declared:
string[] all = info.Type.Assembly.GetManifestResourceNames();
foreach (string resourceStr in all)
{
if (!String.IsNullOrEmpty(resourceStr) && resourceStr.EndsWith(String.Format(".{0}", iconName), true, CultureInfo.CurrentCulture))
{
Stream file = info.Type.Assembly.GetManifestResourceStream(resourceStr);
if (file != null)
{
info.Icon = Image.FromStream(file);
}
}
}

Resources