I have recorded a test case with KAR 3.8.2 on Chrome 75.0.3770.142, but upon replay the Type command is not working for one of the steps.
Here is what happens when I run the script:
So I am not sure if the Click is working, but for now I really need the Type to work.
As a bonus I would love to get XPath to work to shorten the “id” field. The ID field is semi-dynamic (doesn’t always change, especially if you don’t force a refresh). So how can I take “id=M_layout_content_PCDZ_MMCA7G7_ctl00_webInputForm_txtLoginName” and do something like “id$=‘txtLoginName’”?
@rick.bullard I have never used Katalon Extension but if it allows you to have your own selector for an element instead of given by Katalon Extension itself then changing it would be easy.
Can you please post the html of the element ?
Sorry for the late reply.
Here is the HTML for the element:
<div id="xyz1234xyz_ctl00_webInputForm_LC_Zone0" class="vertical_layout">
<div id="xyz1234xyz_ctl00_webInputForm_txtLoginName_C" class="p">
<label for="xyz1234xyz_ctl00_webInputForm_txtLoginName" class="field_label">User ID</label><span><input name="$xyz1234$xyz$ctl00$webInputForm$txtLoginName" type="text" autocomplete="off" maxlength="100" id="xyz1234xyz_ctl00_webInputForm_txtLoginName" class="input_box full_width" autofocus /><span id="xyz1234xyz_ctl00_webInputForm_txtLoginName_RFV" title="Enter your User ID." style="display:none;"></span></span>
<div id="xyz1234xyz_ctl00_webInputForm_txtPassword_C" class="p">
<label for="xyz1234xyz_ctl00_webInputForm_txtPassword" class="field_label">Password</label><span><input name="$xyz1234$xyz$ctl00$webInputForm$txtPassword" type="password" autocomplete="off" id="xyz1234xyz_ctl00_webInputForm_txtPassword" class="input_box full_width" /><span id="xyz1234xyz_ctl00_webInputForm_txtPassword_RFV" title="“Password” is a required field." style="display:none;"></span></span>
@rick.bullard This won’t help. I would need something like this :
- Right-click on the code which you want to select from the list and click on Inspect Element. It will open developer tools and then from there, you can see what are the selectors available.
Well I see it didn’t put my screenshots in.
Here is the code for UserID:
<input name="M$layout$webInputForm$txtLoginName" type="text" autocomplete="off" maxlength="100" id="M_layout_webInputForm_txtLoginName" class="input_box full_width" autofocus="">
<input name="M$layout$webInputForm$txtPassword" type="password" autocomplete="off" id="M_layout_webInputForm_txtPassword" class="input_box full_width">
@rick.bullard The screenshots are still not showing up.
I don’t understand I didn’t do screen shots last time. I pasted text.
Let me try again. And Ugh you can’t just paste HTML in without it disappearing. So please ignore the spaces at the < and >.
< input name="M$layout$webInputForm$txtLoginName" type="text" autocomplete="off" maxlength="100" id="M_layout_txtLoginName" class="input_box full_width" autofocus="" >
< input name="M$layout$webInputForm$txtPassword" type="password" autocomplete="off" id="M_layout_webInputForm_txtPassword" class="input_box_full_width" >
Can you try this :
OK, I get the following:
[error] Invalid xpath : //input[@id=‘M_layout_txtLoginName’]
Ideally I would like something like this:
@rick.bullard Can I access your test website ?
User id :
Have you tried without XPath in the target box with the new ids from your posted code?
I note that they are different from the ids in your original post without all the extra text i.e.
content_PCDZ_MMCA7G7_ctl00_webInputForm is missing
I get the following error:
[error] Invalid xpath : //*[contains(@id, ’webInputForm_txtLoginName’)]
This is true if I use ‘_webInputForm_txtLoginName’ or ‘webInputForm_txtLoginName’.
The extra part (ie content_PCDZ_MMCA7G7_ctl00_webInputForm) is the dynamic part of the ID and part of the bonus option I mention. This data was in the original post (once Russ helped me out). And I just shortened the data in subsequent responses as Manpreet was providing the help I needed (ie getting XPath formatting correct).
Unfortunately Katalon Automation Recorder and Chrome are either not working together or my setup is somehow getting in the way. I say that because everything I have found on the web regarding KAR, XPath, etc. and what Manpreet is suggesting all matches up, but still with no viable results.
@rick.bullard What I am understanding from here there is some inner working of Katalon IDE that is giving us this issue. As I mentioned that I have never used IDE. I do all the automation work in Katalon Studio. I will give this scenario a try this morning in my Katalon Studio Project and share my findings.
@rick.bullard So I tried this with Katalon Studio not Katalon Recorder (IDE) and it worked.
I created 2 objects :
And used them in the script :
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
WebUI.click(findTestObject('New Folder/Page_Sign In - Cedar Point FCU/User_ID'), FailureHandling.STOP_ON_FAILURE)
WebUI.sendKeys(findTestObject('New Folder/Page_Sign In - Cedar Point FCU/User_ID'), 'test')
WebUI.setEncryptedText(findTestObject('New Folder/Page_Sign In - Cedar Point FCU/Password'), 'P9ET2sDE0SE=')
It worked :
OK, so I won’t be able to use Studio as I am using Recorder as a front end scripting tool fro CA’s (Broadcom) ASM WebDriver tool. And they only accept XML as an input form, as such I havent’ been able to fiugre out how to export a Studio project into XML.
Also I have been able to get the basic script to work with the Firefox extension. However, I can only use the full ID or XPath as any shortened version (i.e. to handle dynamic ID’s) has either failed with invalid xpath or just not actually clicked/typed. It feels like Recorder doesn’t handle the full XPath capabilities.
For record keeping the full paths that work are:
xpath=(.//*[normalize-space(text()) and normalize-space(.)=‘User ID’])/following::input
@rick.bullard If you want can you give specify the work flow you are trying to achieve ?
You want to run the XML generated by Katalon on another tool ?
Well, first I am just trying to get Katalon Recorder to work as I need it to. Once I can build a successful script (still more to go besides entering username and password) I will export to XML and upload that into a third party automation app.
Entering the username and password is currently my roadblock as I need to use a dynamic ID (not just this one site but I will be doing this for hundreds, with similar but not exact labels) to enter them.