Creating a UI object repository for webdriver - webdriver

For those familiar with automated testing tools, you know that they all have some kind of "object repository" that stores a mapping of UI elements with identifiers. I have found this to be indispensible and I want to duplicate this for webdriver. Has anyone done this ? Any tips ? Google not helping on this one. C# examples if you can, thanks

I use Webinator (which wraps around WebDriver) but the idea is the same - I usually do a static "Map" class like so:
public static class CollectionMap
{
public static Locator
LocatorTitle = new Locator(FindBy.Id, "Title"),
LocatorDescription = new Locator(FindBy.Id, "Description"),
LocatorSave = new Locator(FindBy.Id, "submit"),
LocatorDelete = new Locator(FindBy.XPath, "//*[contains(#class,'deleteBox')]/a"),
LocatorDeleteConfirm = new Locator(FindBy.Id, "delete-collection-dialogConfirmationLink"),
LocatorCancel = new Locator(FindBy.Id, "cancel");
}
Used like this:
web.Click(CollectionMap.LocatorSave, WaitUntil.AjaxOrPostCompleted());

I am creating multiple classes containing mappings to locators. Each class corresponds to a logical grouping of screen elements.
public class TopLevel
{
public const string username = "ctl00_ctl00_Main_Main_txtUsername";
}

Related

How create a WorkQueue Guidewire?

I need create a workqueue in guidewire, but not find guidewire documentation about this.
Someone can help me please?
Regards,
Douglas Rezende
You need several things:
Make a new Typecode in BatchProcessType typekey (For example MyNewCode). Additionally you need add categories: Schedulable, UIRunnable or APIRunnable according to your need.
Make a new class that extends WorkQueueBase like this
class MyWorkQueue extends WorkQueueBase<Message, StandardWorkItem> {
private final static var _batchProcessType = BatchProcessType.TC_MYNEWCODE
construct() {
super(_batchProcessType, StandardWorkItem, Message)
}
override function findTargets(): Iterator<Message> {
return Query.make(Message).select().iterator()
}
override function processWorkItem(p0: StandardWorkItem) {
var bean = extractTarget(p0)
// My process
}
}
Register the new class in work-queue.xml. You can search in the documentation additional parameters like retryLimit, retryInterval, server, env, maxpollinterval, etc.
<work-queue workQueueClass="example.MyWorkQueue" progressinterval="600000">
<worker instances="1" batchsize="5" />
</work-queue>
Register the new BatchProcessType in scheduler-config.xml (Optional). For it works correctly the typecode needs the Schedulable category (first step)
<ProcessSchedule process="MyNewCode">
<CronSchedule minutes="*/10" />
</ProcessSchedule>

SQL Table to SiteMapProvider 4 ASP.net mvc4

I have been trying to use SiteMapProvider from NuGet and make it link to a database in order to get all the links for a sidebar and breadcrumb, so far I don't find any tutorial, and I keep getting stuck using the information to the xml file, I am sure that I have to create a class, but I don't seem to find any tutorial on how to do this, or how to correctly make the call to this class, is there a tutorial or any website that contain this information? I have been trying to do what is included in here:
https://github.com/maartenba/MvcSiteMapProvider/wiki/Dynamic-sitemaps
But I don't know how to define the dynamicNodeProvider, any help? Sorry if it's some what vague what I am asking.. I have tried to search but I haven't find any information..
EDIT:
I was able to load information using :
[MvcSiteMapNode(Title = "HOLDCREATEREPORT", ParentKey = "Home", Key = "CreateReport")]
on each, class, but I am more interested in doing this using a unique class that loads all nodes, I have tried so far to change the sitemap xml to the following code:
navigation itself has the following code:
public class navigation : DynamicNodeProviderBase
{
public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
{
for (int i = 0; i < 20; i++)
{
DynamicNode dynamicnode = new DynamicNode();
dynamicnode.Title = "test"+ i.ToString();
dynamicnode.ParentKey = "Home";
dynamicnode.RouteValues.Add("test" + i.ToString(), "abcdb"+ i.ToString());
yield return dynamicnode;
}
}
}
yet when I run it nothing gets displayed, I am pretty sure I am missing something extremely easy >_>.
Dynamic Node Providers require a definition node. The definition node can either be in XML or as a .NET attribute. It won't be included in the SiteMap, but the nodes that the Dynamic Node Provider create will be.
[MvcSiteMapNode(Title = "Dynamic Nodes", DynamicNodeProvider = "MyNamespace.navigation, MyAssembly")]
Or
<mvcSiteMapNode title="Dynamic Nodes" dynamicNodeProvider="MyNamespace.navigation, MyAssembly">

Factory Method implementation in actionscript

Hey folks, i ve got this issue implementing the Factory method.
Following is the snippet of the the main chart class which calls ChartFactory's method to attain the proper object. I Type Cast chartobject so as to be able to call the Show method;i m apprehensive about that as well.
container = new VBox();
container.percentWidth = 100;
container.percentHeight = 100;
super.media.addChild(container);
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
IChart(chartObject).Show(o);
container.addChild(chartObject);
legend = new Legend();
legend.dataProvider = IChart(chartObject);
container.addChild(legend);
Following is the snippet of ChartFactory's method:
public static function CreateChartObject(subType:String):ChartBase
{
switch(subType)
{
case ChartFactory.AREA_CHART:
return new AreaCharts();
break;
case ChartFactory.COLUMN_CHART:
return new ColumnCharts();
break;
case ChartFactory.PIE_CHART:
return new PieCharts();
break;
default:
throw new ArgumentError(subType + ": Chart type is not recognized.");
}
}
And following is Show method of one of the several Charts type classes: AreaCharts, PieCharts etc. All of which implements IChart Interface.
public function Show(o:ObjectProxy):void
{
var grids:GridLines;
var stroke:SolidColorStroke;
var horizontalAxis:CategoryAxis;
var verticalAxis:LinearAxis;
var horizontalAxisRenderer:AxisRenderer;
var verticalAxisRenderer:AxisRenderer;
grids = new GridLines();
if(WidgetStylesheet.instance.LineChart_ShowGrid)
grids.setStyle("gridDirection", "both");
else
grids.setStyle("gridDirection", "");
stroke = new SolidColorStroke(WidgetStylesheet.instance.LineChart_GridLineColor, WidgetStylesheet.instance.LineChart_GridLineThickness);
grids.setStyle("horizontalStroke", stroke);
grids.setStyle("verticalStroke", stroke);
horizontalAxis = new CategoryAxis();
horizontalAxis.categoryField = o.LargeUrl.Chart.xField;
horizontalAxis.title = o.LargeUrl.Chart.xAxisTitle.toString();
verticalAxis = new LinearAxis();
verticalAxis.title = o.LargeUrl.Chart.yAxisTitle.toString();
horizontalAxisRenderer = new AxisRenderer();
horizontalAxisRenderer.axis = horizontalAxis;
horizontalAxisRenderer.setStyle("tickLength", 0);
horizontalAxisRenderer.setStyle("showLine", false);
horizontalAxisRenderer.setStyle("showLabels", true);
horizontalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
verticalAxisRenderer = new AxisRenderer();
verticalAxisRenderer.axis = verticalAxis;
verticalAxisRenderer.setStyle("tickLength", 0);
verticalAxisRenderer.setStyle("showLine", false);
verticalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
this.series = this.m_createSeries(o);
this.horizontalAxis = horizontalAxis;
this.horizontalAxisRenderers = [horizontalAxisRenderer];
this.verticalAxis = verticalAxis;
this.verticalAxisRenderers = [verticalAxisRenderer];
this.backgroundElements = [grids];
}
I'm afraid that there is more than one issue with this code. Unfortunately it is not obvious why your chart doesn't show up so you may apply some of advices below and use debugger to analyse the issue.
There is no point in creating ChartBase instance if you are going to change value of chartObject reference in the next line
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
If the API of your charts is IChart your factory should return IChart instead of casting.
public static function CreateChartObject(subType:String):IChart
Make sure that you are returning instances of the correct class from the factory. i.e. that you are returning your subclass of standard PieChart. Generally it's not the best idea to extend the class keeping the same name and just changing the package.
Once again, if you are not sure if the program enters some function use the Flash Builder debugger to check this. I can't imagine development without debugger.
Some thoughts:
you call the Show method, pass it some object but nowhere in that method is any child added to a displayObject. What exactly is Show supposed to do?
a lot of member variables in your classes start with UpperCase. The compiler can easily confuse those with class names, in case your classes are named the same. Bad practice to start variable and function names with capitals.
If your casting an instance to another class or interface fails, you will get a runtime error. Those are easy to debug using the Flash Builder debugger.
Hey ppl..
i found out wat wnt wrng..as olwys it wa "I".
I ve a habit of mkin mock ups secluded from the main project n dn integrate it. So in mock up i hd used an xml whch hd a format slightly diff dn d one being used in the main project.
N i hd a conditional chk to return from the prog if certain value doesnt match, n due to faulty xml i did'nt.
So this more a lexical error than a logical one.
Sorry n Thanx evryone for responding.

ClearCanvas DicomFile.DataSet -- How to add a new Tag?

im trying to add a new tag to my DicomFile.DataSet in ClearCanvas.
I notice there is the method "DicomFile.DataSet.RemoveAttribute" but no "AddAtribute" method. So I have been looking at the method "LoadDicomFields" & "SaveDicomFields" but so far can't seem to get them to work. Ive tried to pass in a "DicomFieldAttribute" to these methods, but to no avail.
What am I missing here? Or what do I need to do to add a new tag to the DataSet.
DicomFieldAttribute c = new DicomFieldAttribute(tag);
List<DicomFieldAttribute> cs = new List<DicomFieldAttribute>();
cs.Add(c);
DicomFile.DataSet.LoadDicomFields(cs);
DicomFile.DataSet.SaveDicomFields(cs);
if(DicomFile.DataSet.Contains(tag))
{
tag = 0; //BreakPoint never reached here
}
Or I tried this as well::
DicomFieldAttribute c = new DicomFieldAttribute(tag);
DicomFile.DataSet.LoadDicomFields(c);
DicomFile.DataSet.SaveDicomFields(c);
if(DicomFile.DataSet.Contains(tag))
{
tag = 0; //BreakPoint never reached here
}
Ive been stuck on what would seem to be a trivial task.
You're confusing a bit the use of attributes. The DicomFiledAttribute is a .NET attribute that can be placed on members of a class so that the class is automatically populated with values from a DicomAttributeCollection or or to have the class automatically populated with values from the DicomAttribute Collection. Ie, given a test class like this:
public class TestClass
{
[DicomField(DicomTags.SopClassUid, DefaultValue = DicomFieldDefault.Default)]
public DicomUid SopClassUid = null;
[DicomField(DicomTags.SopInstanceUid, DefaultValue = DicomFieldDefault.Default)]
public DicomUid SOPInstanceUID = null;
[DicomField(DicomTags.StudyDate, DefaultValue = DicomFieldDefault.Default)]
public DateTime StudyDate;
}
You could populate an instance of the class like this:
DicomFile file = new DicomFile("filename.dcm");
file.Load();
TestClass testInstance = new TestClass();
file.DataSet.LoadDicomFields(testInstance);
// testInstance should now be populated with the values from file
If you're interested in just populating some DICOM tags, the DicomAttributeCollection has an indexer in it. The indexer will automatically create a DicomAttribute instance if it doesn't already exist, for the tag requested via the indexer. So, to populate a value, you can do soemthing like this:
DicomFile file = new DicomFile("filename.dcm");
file.DataSet[DicomTags.SopInstanceUid].SetStringValue("1.1.1");
If you want to create the DicomAttribute yourself, you can do something like this:
DicomAttribute attrib = new DicomAttributeUI(DicomTags.SopInstanceUid);
attrib.SetStringValue("1.1.1");
DicomFile file = new DicomFile("filename.dcm");
file.DataSet[DicomTags.SopInstanceUid] = attrib;

NVelocity -- #parse with embedded resources

I'm generating emails based off embedded NVelocity templates and would like to do something with dynamically included sections. So my embedded resources are something like this:
DigestMail.vm
_Document.vm
_ActionItem.vm
_Event.vm
My email routine will get a list of objects and will pass each of these along with the proper view to DigestMail.vm:
public struct ItemAndView
{
public string View;
public object Item;
}
private void GenerateWeeklyEmail(INewItems[] newestItems)
{
IList<ItemAndView> itemAndViews = new List<ItemAndView>();
foreach (var item in newestItems)
{
itemAndViews.Add(new ItemAndView
{
View = string.Format("MyAssembly.MailTemplates._{0}.vm", item.GetType().Name),
Item = item
});
}
var context = new Dictionary<string, object>();
context["Recipient"] = _user;
context["Items"] = itemAndViews;
string mailBody = _templater.Merge("MyAssembly.MailTemplates.DigestMail.vm", context);
}
And in my DigestMail.vm template I've got something like this:
#foreach($Item in $Items)
====================================================================
#parse($Item.viewname)
#end
But it's unable to #parse when given the path to an embedded resource like this. Is there any way I can tell it to parse each of these embedded templates?
Hey Jake, is .viewname a property? I'm not seeing you setting it in your code, how about you use the following:
#foreach($Item in $Items)
====================================================================
$Item.viewname
#end
I don't know why you're parsing the $Item.viename rather than just using the above? I'm suggesting this as I've just never needed to parse anything!
Please refer to this post where we've discussed the generation of templates.
Hope this helps!

Resources