Jump to content

how to use xpath in IE


Recommended Posts

  • Moderators

@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.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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")

Link to comment
Share on other sites

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].

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'))

Link to comment
Share on other sites

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...