The xpath contained with font tagname not working in Katalon web testing

while I check using chropath It is working but In Katalon execution time it is not working
please can anyone help on this

//font[contains(text(),‘3-October-2020’)]

Yes. The screenshot you attached above proves that the ChroPath tool showed the xpath string. However, the screenshot does not prove that you did everything right in Katalon Studio. For example, you may have made one character typo in Katalon Studio.

Please show what you did in Katalon Studio: screenshot of your test case script and TestObject definition.

One other test you can try is to click in the code window, then hit CTRL + F key combo. This brings up the “Find by…” textbox. Copy and paste your XPath in the textbox. To the right of the textbox, do you get “1 of 1” appear. If not, then that is the concern.
image

If nothing appears to the right, then your XPath is deemed not valid. You will have to “fix” it. If you copy and paste the date, 3-October-2020, from the code window into your XPath, then you could remove the contains option from the concern; //font[text()=‘3-October-2020’]

If you get 1 of n, then your XPath is not unique and you will have to amend it so it becomes unique.

Ya… That xpath working fine in Browser console while testing manually but katalon execution time only not identifying the object

You should pay attention to the timing when you apply the xpath to the target web page.

When you try verifying the xpath in the browser console, the page has surely finished loading some seconds ago, so all HTML nodes are there. In this situation you do not have any timing issue.

On the other hand, when you run a Katalon test case script, you should pay attention to the timing issue. You need to make sure that the target HTML node is completely loaded before you apply locators. It is possible that page loading takes longer than you expect. If your script is hasty trying to find a HTML node which is yet to be loaded in an instant, then the script will fail to find the node.

You can use WebUI.waitForElementPresent(TestObject, int timeoutSeconds) , WebUI.verifyElementPresent(). Or WebUI.delay(int seconds) makes your script just wait as long as you want.

Can I also ask what are you trying to have KS do with a FONT?

Ya used both two WebUI.waitForElementPresent(TestObject, int timeoutSeconds) , WebUI.verifyElementPresent()
but still it is giving element not found issue
This is my xpath “//font[contains(text(),‘3-October-2020’)]/…/…/…//font[text()=‘Nursing Student’]/…/…/…//font[text()=‘Accounting’]/…/…/…//td[text()=‘One Time’]/./…/…//td[contains(text(),‘2 : 0’)]/…//td[contains(text(),‘Not Applied’)]/…//button[2]”
in console log it is working

Terrible expression! This is not a valid XPath at all.

Did you use KatalonRecorder? ---- no, Recorder is not as bad as this.

/…/

What is this? I do not think this is a valid notation in XPath.

ya… that is /… while I copied it came as /…

It seems you need to learn the basics of XPath. Have a look at the following artcile.

https://www.guru99.com/xpath-selenium.html

//font[contains(text(),‘3-October-2020’)]/…/…/…//font[text()=‘Nursing Student’]/…/…/…//font[text()=‘Accounting’]/…/…/…//td[text()=‘One Time’]/./…/…//td[contains(text(),‘2 : 0’)]/…//td[contains(text(),‘Not Applied’)]/…//button[2
this is real Xpath

and I coded manually… and I used parametrization
WebUI.waitForElementPresent(findTestObject(‘Volunteer/Opportunity/ApplyForOpportunity/btn_applyOpportunity’,[(‘startDate’):data_startDate, (‘profession’):data_profession, (‘unit’):data_unit, (‘type’):data_type, (‘needsAndBids’):data_needsAndBids, (‘status’):data_status ]),4)

if i put one dot it is coming as two dots

In above table there may be several records…so if I want to click on particular record’s action button we need use above six parameter values to identify …so how can we minimize the xpath and how can we perform on this…?
plz suggest a solution

First you want to identify a single <tr> element in a <table> in the web page by looking at the text in the contained <td> elements. You can do it by XPath Predicate. Once you identified a <tr> element of your interest, then you can find a <button> element as a descendent of the <tr>.

See the “Predicates” section in https://www.w3schools.com/xml/xpath_syntax.asp

Something like this:

//table/tbody/tr[contains(td[1],'3-October-2020)'][contains(td[2],'Custom Shift')][contains(td[3], 'Nursing Student')][contains(td[4], 'Accounting')][contains(td[7], '2:0')][contains(td[8], 'NOT APPLIED')]/td[9]/button[2]

I can not verify if this code works against your Application Under Test, so it would almost certainly fail. I would like to ask you to refine it and make it work.

ok I ll try and let you know

//table/tbody/tr[contains(td[1],‘3-October-2020’)][contains(td[3],‘Nursing Student’)][contains(td[4],‘Accounting’)][contains(td[5],‘One Time’)][contains(td[7],‘2 : 0’)][contains(td[8],‘Not Applied’)]/td[9]/button[2]//span[contains(text(),‘check_circle’)]

above Xpath working > but same issue it is working in Browser console and not working in Katalon execution time

and used waitforElement and verifyElement and delay as well

Does your HTML contain any <iframe> ?

I’m sorry it has taken me this long to notice this topic.

@Mohamed_Sajjaath You should report the Website as failing HTML standards and tell the developers to fix it.

As you can see, it’s not even deprecated, it’s obsolete!