|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 5 of 5 total|
|Automated testing, and div naming|
|Mon, Jun 26 2017 7:26 AM||Permanent Link|
Has anyone done any automation of WebBuilder apps? I'd like to have a basic regression test suite for my application, as I keep breaking some minor thing while building new stuff. The one I'm looking at at the moment is GhostInspector. However, it uses named div's to work out if things are working, and looking at my application in the browser, all the divs have no classname and no id. Is it possible for my code to add these? Or ideally, for them to be added automatically?
I realise that it might reveal information, but perhaps it could be optional. I also have multiple instances of the same form, so "Edit1" will occur more than once, so a way to intercept or make the id relate to the parent name too might be good.
Anyway, if anyone has done this sort of thing before, please say...
|Mon, Jun 26 2017 9:35 AM||Permanent Link|
Quick test shows how it behaves:
Click on input[name="editEmail"]
Assign mj into input[name="editEmail"]
Click on div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(4) > div:nth-of-type(3) > div:nth-of-type(3) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > div > div > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(4)
ELEMENT NOT FOUND
|Mon, Jun 26 2017 10:14 AM||Permanent Link|
This appears to work:
Button1.ClientElement.Id := 'HelloMum';
It is only affecting the top level of the button, and I'm not sure how this would affect the clicks, as the other elements of the button also have the OnClick active.
I guess I'd have to traverse all the child elements and name them too.
I think I'd be happy to traverse the whole DOM to fill this in. One risk of course is that I break framework code that uses the names/id's of elements. I guess just leaving anything that has a name would be the ideal anyway.
Got to stop for the day, so will pick up later.
|Mon, Jun 26 2017 1:46 PM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< This appears to work: >>
Yes, that is the correct way to handle this.
<< It is only affecting the top level of the button, and I'm not sure how this would affect the clicks, as the other elements of the button also have the OnClick active. >>
Yes, but they all end up getting dispatched to the top-level element, the interface controller (TInterfaceController) anyway, so they don't really matter. IOW, as long as you assign an ID to the interface controller elements, then you will be able to trigger/test clicks on a particular control.
<< I guess I'd have to traverse all the child elements and name them too. >>
No, that won't be necessary.
<< I think I'd be happy to traverse the whole DOM to fill this in. One risk of course is that I break framework code that uses the names/id's of elements. I guess just leaving anything that has a name would be the ideal anyway. >>
EWB only uses the element names for HTML forms. Apart from that, it does not care about element IDs/names.
|Tue, Jun 27 2017 10:17 AM||Permanent Link|
Matthew Jones wrote:
> Has anyone done any automation of WebBuilder apps?
Okay, a basic working version. In the FormCreate, call:
And that does enough to make app.ghostinspector.com work well enough. The 'jo' is the form identifier prefix, to keep things unique.
In the code below, g_xAppendValues is a TStringList global that can be used to make all items uniquely numbered, but I wanted forms of the same type to get the same number order for each one, so an intermediate list is used if it encounters a form. You can make one call for your parent form and everything is plastered, or do it individually.
I expect people will want to customise, but this is good starter code. The Copy calls are snipping the T or Tfrm from names.
function GetNextItemName(szSuffix : String; szComponentType : String; xList : TStringList = nil) : String;
szCurrent : String;
nValue : Integer;
if not assigned(g_xAppendValues) then
g_xAppendValues := TStringList.Create;
if not assigned(xList) then
xList := g_xAppendValues;
szCurrent := xList.Values[szComponentType];
nValue := StrToIntDef(szCurrent, 1);
xList.Values[szComponentType] := IntToStr(nValue + 1);
if szSuffix <> '' then
szSuffix := '-' + szSuffix;
Result := 'XA' + szComponentType + szSuffix + IntToStr(nValue);
procedure AddItemIDsInternal(xControl : TControl; szParentName : String; xNameList : TStringList);
nLoop : integer;
xComp : TControl;
szCompType : String;
for nLoop := xControl.ControlCount - 1 downto 0 do
xComp := xControl.Controls[nLoop];
if TControlAccessor(xComp).ClientElement.id = '' then
szCompType := Copy(xComp.classname, 2, 99);
TControlAccessor(xComp).ClientElement.id := GetNextItemName('', szParentName + '-' + szCompType, xNameList);
if xComp is TFormControl then
szParentName := szParentName + '=' + Copy(xComp.ClassName, 5, 99);
AddItemIDsInternal(xComp, szParentName, xNameList);
procedure AddItemIDs(xControl : TControl; szParentName : String);
nLoop : integer;
xComp : TControl;
xNameList : TStringList;
if not g_bEnableItemIDs then
if szParentName = '' then
szParentName := Copy(xControl.classname, 2, 99);
xNameList := TStringList.Create();
AddItemIDsInternal(xControl, szParentName, xNameList);
This web page was last updated on
Sunday, March 26, 2023 at 04:50 AM
© 2023 Elevate Software, Inc. All Rights Reserved
Questions or comments ? E-mail us at firstname.lastname@example.org