Jump to content
vick

how to use xpath in IE

Recommended Posts

vick

i saw IEbyXPATH . but i do not see UDF. from where i can get it and how i can use it?

 

Share this post


Link to post
Share on other sites
vick

so i have to save that content as UDF and use it. but can i have some example if you have?

Share this post


Link to post
Share on other sites
jdelaney

If you provide the html structure, I can help with the function call and xpath..


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
vick

thanks i will try first and if not worked then ask you.

thanks again

Share this post


Link to post
Share on other sites
vick

Hi,

I have tried something like below but not worked. can you tell me what is wrong here pls?

$xpathForumLink = "//a[@class='bg_P']"

$oIE = _IECreate("https://google.ca",True,True)
Sleep(2000)
$aForumLink = BGe_IEGetDOMObjByXPathWithAttributes($oIE,$xpathForumLink)
_IEAction($aForumLink,"click")

Share this post


Link to post
Share on other sites
vick

i am trying to click Gmail on google .ca page

Share this post


Link to post
Share on other sites
vick

i am getting something like in console log:

 IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
Start Function=[BGe_IEGetDOMObjByXPathWithAttributes] with $sXPath=[//a[@class='bg_P']].
Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[a], $bNodeIsRelative=[True] $bIsConstrainted=[True].
Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[a], $bNodeIsRelative=[True] $bIsConstrainted=[True].
Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[a], $bNodeIsRelative=[True] $bIsConstrainted=[True].
Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[a], $bNodeIsRelative=[True] $bIsConstrainted=[True].

Share this post


Link to post
Share on other sites
vick

yes sir. it worked. i am wondering how can i be so stupid?:(

Share this post


Link to post
Share on other sites
vick

sorry one question came up why we have to put 0 in below code?

If IsArray($aForumLink) Then _IEAction($aForumLink[0],"click")

Share this post


Link to post
Share on other sites
vick

if i have table like below:

"//table[@id='_ctl0__ctl39__ctl0__ctl1_wgWorkItems__baseGrid']/tbody/tr[4]/td[3]"

how i can get text from it in loop or without loop?

Share this post


Link to post
Share on other sites
Danp2
22 minutes ago, vick said:

if i have table like below:

"//table[@id='_ctl0__ctl39__ctl0__ctl1_wgWorkItems__baseGrid']/tbody/tr[4]/td[3]"

how i can get text from it in loop or without loop?

So you are trying to retrieve the text from 3rd cell from the 4th row?

You could try

_IEPropertyGet($aResult[0], 'innertext')

where $aResult is the resulting array from the prior call to BGe_IEGetDOMObjByXPathWithAttributes

Share this post


Link to post
Share on other sites
vick

i tried that way but getting this error:

Start Function=[BGe_IEGetDOMObjByXPathWithAttributes] with $sXPath=[//input[@id='_ctl0__ctl39__ctl0__ctl0_btnFind']].
Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[input], $bNodeIsRelative=[True] $bIsConstrainted=[True].
Start Function=[BGe_IEGetDOMObjByXPathWithAttributes] with $sXPath=[//table[@id='_ctl0__ctl39__ctl0__ctl1_wgWorkItems_tblWebGrid']/tbody/tr[4]/td[3]].
ParseXPathConstraint: Callers XPath/Node/Conditions not well formed=[4]
ParseXPathConstraints: Callers XPath/Node/Conditions not well formed=[4]
ParseXPath: Callers XPath/Node/Conditions not well formed=[tr[4]]
BGe_IEGetDOMObjByXPathWithAttributes: Callers XPath/Node/Conditions not well formed=[//table[@id='_ctl0__ctl39__ctl0__ctl1_wgWorkItems_tblWebGrid']/tbody/tr[4]/td[3]]
"C:\Users\patelvi.DIAGLABS\Desktop\temp.au3" (68) : ==> Expected a variable in user function call.:
MsgBox(0,"",_IEPropertyGet($vp[0],'innertext'))

Share this post


Link to post
Share on other sites
jdelaney

It's much easier to grab the table, and then throw that object into:

_IETableWriteToArray

But it looks like you aren't using the most current function I provided, where it allows for the [#]...I'll look at my post, and make sure it's updated in a bit.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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

×