cancel
Showing results for 
Search instead for 
Did you mean: 

EvaluateXpath

New Contributor

EvaluateXpath

HI,

I am Working On Web testing In Test Complete With Python Script.

1. I Have Saved My XPath In Unit1

2. I Created An Method In unit2.

3.In The Unit2 Method i Used EvaluateXPath method.

4.Now I need to Call The Unit1 Savd XPath In To The EvaluateXPath()

inside those braces.

 

5. Please Tell Me How To Call Method From One Unit To Another Unit inside Those Braces

 

unit1

def test():

a= "//input[@value='Login']"

 

Unit2

p = Sys.Browser("*").Page("*")

arr = p.EvaluateXPath(?..............Send Me the Answer For This Function)

 

 

 

 

 

 

 

5 REPLIES 5
Community Hero

Re: EvaluateXpath

Hi,

 

Does https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/... help?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
New Contributor

Re: EvaluateXpath

HI,

Alex

Thank You For the repley But my method is different

 

unit1 XPATH

a="//input[@value='Login']"

 

Unit2

p=Sys.Browser("*").Page("*")

arr = p.EvaluateXpath(......i need to call that unit 1 into this method.....)

i need that Xpath to Call inside Those Braces...

Pls Tell Me how To Do That...

But in the link it clears that how to call methos from one unit to other but not inside a method

 

 

 

 

 

New Contributor

Re: EvaluateXpath

Hi Alex,

 

If it is possible shall we contact through video call or normal call

 is their any pluggins to resolve it

 

Community Hero

Re: EvaluateXpath

Hi,

 

> a="//input[@value='Login']"

I am not an expert with Python, but for me your example looks like that you would like to have public method or variable in Unit1 and use it from Unit2. If the method/variable is public, it does not matter if you use it inside braces or assign to a local variable and use this variable then.

So my current understanding is that you need to make some methods and/or variables in one unit to be public and then use them from another unit.

I think that the referenced article describes how this can be done.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: EvaluateXpath

Hi @Vimalan ,

 

in unit1 please specify the xpath as a string as mentioned below.

Unit1:

strSubmitButton = '//button[contains(@type, "submit")]'

in unit2 import the unit1 and use the string mentioned in unit1 as mentioned below.

import Unit1
  
def testingXpath():
  page = Sys.Browser("chrome").Page("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_type")
  # Call the function 
  arr = page.EvaluateXPath(Unit1.strSubmitButton)
  # Check the Object and highlight the object 
  if GetVarType(arr) != varNull:
    Sys.HighlightObject(arr[0],2)

please do let me know if this resolved your problem.

 

Kind Regards,

Sathish Kumar

Regards,
Sathish Kumar K
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors