vick

how to use xpath in IE

23 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

P.S. You posted in the wrong forum

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

#4 ·  Posted

@vick Please pay attention to where you post in the future. The Examples forum very clearly states:

Quote

Do not post general support questions here, instead use the AutoIt Help and Support forums.

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

@vick The examples are built into the UDF. Look for the section beginning with

#region SAMPLE

;)

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

#7 ·  Posted

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

thanks again

Share this post


Link to post
Share on other sites

#8 ·  Posted

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

#9 ·  Posted

You'll need to check the result to see if it's an array before proceeding --

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

For me, your code failed to find a matching element. Which link are you attempting to click?

Share this post


Link to post
Share on other sites

#10 ·  Posted

i am trying to click Gmail on google .ca page

Share this post


Link to post
Share on other sites

#11 ·  Posted

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

#12 ·  Posted

You've got the class wrong. It's 'gb_P', not 'bg_P'. :D

Share this post


Link to post
Share on other sites

#13 ·  Posted

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

Share this post


Link to post
Share on other sites

#14 ·  Posted

Just a silly mistake...

Share this post


Link to post
Share on other sites

#15 ·  Posted

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

#16 ·  Posted

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

#17 ·  Posted

44 minutes ago, vick said:

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

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

[0] - first matching link

[1] - second matching link

etc

Share this post


Link to post
Share on other sites

#18 ·  Posted

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

#19 ·  Posted

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

#20 ·  Posted (edited)

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