Jump to content
TheOne23

how to use UIWRAPPER.AU3 or CUIAutomation2.au3 to manipulate a website

Recommended Posts

Hi Expert and MVPs,

I would like to ask your assistance on how to use uiwrapper or cuiautomation2.au3 to manipulate a certain webisite like below sample website where I am unable to set a text or highlight the exact object such as the input box but Buttons I am able to highlight and click.

Sample website: https://www.vistahcmselfservice.adp.com/Phl/ 

This website is just a sample where it has same behavior of having java script.

You may give me other sample sites if you prefer to.

Below is my code that i referred to the Simple UIA Spy

#include "CUIAutomation2.au3"
#include "UIAWrappers.au3"

_UIA_setVar("oUIElement","Title:=;controltype:=UIA_EditControlTypeId;class:=") ;ControlType:=UIA_EditControlTypeId;classname:=")
_UIA_action("oUIElement","focus")
_UIA_action("oUIElement","highlight")
_UIA_action("oUIElement","setValue", "testing")

 

Share this post


Link to post
Share on other sites

if you are able to focus, highlight and click you can set text in it with 

_UIA_Action

  1. setvalue (or settextvalue as alias) which uses the uia value pattern which is not allways implemented for all types of textcontrols (you should be able to see this with simplespy or inspect)
  2. setvalue using keys which will basically send a ctrl+a to select all existing text before it sends the new text
  3. setvalue using clipboard
  4. sendkeys which just send the keys without wiping first

Share this post


Link to post
Share on other sites

Hi Junkew,

 

Than you for your feedback and inputs. I tried to use the SimpleSpy and used the CTRL+W on the focused item or object. It seems that I am able to highlight the item using the CTRL+W of SimpleSpy but once I tried to put it in the code and run it, it is highlighting different items.

Can you give me some examples using the site I provided? or site you prefer?

In other websites I tried this and It worked.

I am not sure what is the coverage of Simple Spy for a certain website.

 

Your help will be greatly appreciated.

Share this post


Link to post
Share on other sites

You could try with index or indexrelative

index finds the nth element of controltype you gave, in this case edit

indexrelative gives nth element after another found element 

#include "CUIAutomation2.au3"
#include "UIAWrappers.au3"

_UIA_setVar("oUIElement","controltype:=Edit;index:=4") ;ControlType:=UIA_EditControlTypeId;classname:=")
_UIA_action("oUIElement","focus")
_UIA_action("oUIElement","highlight")
_UIA_action("oUIElement","setValue", "testing")

 

Share this post


Link to post
Share on other sites
Posted (edited)

Start with latest version of UIAWrappers 0.7 and examples

Below should work

;~  *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

;~ ~ *** Standard code maintainable ***
_UIA_setVar("oP1","class:=Chrome_WidgetWin_1")  ;:: ESS :: Login Now - Google Chrome
_UIA_setVar("oP2","controltype:=Pane")  ;Google Chrome
_UIA_setVar("oP3","controltype:=Pane;instance:=2")  ;Google Chrome
_UIA_setVar("oP4","controltype:=Pane")  ;Google Chrome
_UIA_setVar("oP5","Title:=;controltype:=Tab")   ;Google Chrome
_UIA_setVar("oP6","Title:=.*Login.*;controltype:=TabItem")  ;Google Chrome

_UIA_setVar("oP7","class:=Chrome_RenderWidgetHostHWND") ;:: ESS :: Login Now
_UIA_setVar("oP8","controltype:=Edit;instance:=2")  ;
_UIA_setVar("oP9","controltype:=Edit;instance:=4")  ;
;~ _UIA_setVar("oP4","Title:=;controltype:=UIA_CustomControlTypeId;class:=")    ;
;~ _UIA_setVar("oP5","Title:=;controltype:=UIA_CustomControlTypeId;class:=")    ;
;~ _UIA_setVar("oP6","Title:=;controltype:=UIA_CustomControlTypeId;class:=")    ;
;~ _UIA_setVar("oP7","Title:=;controltype:=UIA_CustomControlTypeId;class:=")    ;

;~ $oUIElement=_UIA_getObjectByFindAll(".mainwindow", "title:=;ControlType:=UIA_EditControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=;controltype:=UIA_EditControlTypeId;class:=") ;ControlType:=UIA_EditControlTypeId;classname:=")

;~ Actions split away from logical/technical definition above can come from configfiles

_UIA_Action("oP1","setfocus")
;~ _UIA_Action("oP1","highlight")

;~ _UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")

;~ _UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")

;~ _UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")

;~ _UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")

_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")
_UIA_Action("oP6","click")

_UIA_Action("oP1","setfocus")    ;~ This to speed up as this is parent of document p7

_UIA_Action("oP7","highlight")
_UIA_Action("oP7","setfocus")

_UIA_Action("oP8","highlight")
_UIA_Action("oP8","setfocus")
_UIA_Action("oP8","setvalue","whatever1")

_UIA_Action("oP9","highlight")
_UIA_Action("oP9","setfocus")
_UIA_Action("oP9","setvalue","whatever2")

run with chrome and make sure you have chrome accessibility turned on and in one of the tabs you should have the login page open.

See other examples like number 5 about chrome but also other examples deal with chrome browser. In the examples you can see how to open a browser and fill the addressbar to navigate to your location.

 

Edited by junkew

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...