XPATH

(Copy URL in PhpBB Forum Format - Info)

From iMacros

Jump to: navigation, search

XPATH test macro:

TAB T=1     
TAB CLOSEALLOTHERS  
URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp  
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[1]/td[3]/small/input[1]" CONTENT="Tom Tester"
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[2]/td[3]/select" CONTENT=$Pizza
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[3]/td[3]/select" CONTENT=$Water
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[3]/td[3]/input[1]" CONTENT=YES 
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[4]/td[3]/select" CONTENT=$Apple<SP>Pie:$Fruits 
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[5]/td[3]/input[1]" CONTENT=Yes 
SET !ENCRYPTION NO
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[5]/td[3]/input[2]" CONTENT=demo123 
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[6]/td[3]/textarea" CONTENT="Hi!\n\niMacros fills  forms;-)\n\nTom"
TAG XPATH="id('TestForm')/div/center/table/tbody/tr[8]/td[3]/input" 
WAIT SECONDS=5
URL GOTO=http://www.iopus.com/imacros/home/msg/ok.htm

You can use XPath checker to get the element's XPath.

XPath support is available in iMacros 7, iMacros for Firefox and iMacros for Chrome. Due to the different underlying browser engines, not all XPATH commands behave exactly the same on every browser. One case is the id() function as it is used in the example above, which is not supported in iMacros 7. One can get the same result by using instead:

TAB T=1     
TAB CLOSEALLOTHERS  
URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp  
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[1]/td[3]/small/input[1]" CONTENT="Tom Tester"
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[2]/td[3]/select" CONTENT=$Pizza
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[3]/td[3]/select" CONTENT=$Water
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[3]/td[3]/input[1]" CONTENT=YES 
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[4]/td[3]/select" CONTENT=$Apple<SP>Pie:$Fruits 
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[5]/td[3]/input[1]" CONTENT=Yes 
SET !ENCRYPTION NO
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[5]/td[3]/input[2]" CONTENT=demo123 
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[6]/td[3]/textarea" CONTENT="Hi!\n\niMacros fills  forms;-)\n\nTom"
TAG XPATH="//*[@id='TestForm']/div/center/table/tbody/tr[8]/td[3]/input" 
WAIT SECONDS=5
URL GOTO=http://www.iopus.com/imacros/home/msg/ok.htm

Please, notice that the macro above works also in the Firefox and Chrome addons.

If you find problems, please report them to us. Then we can test whether that issue is a bug in our implementation or a restriction of the web browser itself. Having said this, the large majority of XPATH commands behave the same in all iMacros version.


Related forum posts:

Personal tools
Home
Toolbox

Website Monitoring