Trying to call the FindChild method or property of an object but it does not exist
Hello, can someone help debug the following script, I cannot figure it out why it's failing being I am new to TC.
I included the screenshot of the properties from the Spy captured,I am sure the page ID is correct according to the spy screen.
function DragCard()
{
// Find the first column element
var column1 = Sys.Browser("chrome").Page("https://rdx-dev.rdxhub.com/workspace/patient-board").FindChild("idStr", "chk-drop-list-0", 10);
// Find the card element in the first column with the desired text content
var cardToMove = column1.FindChild("contentText", "Test Patient455", 10);
// Find the second column element
var column2 = Sys.Browser("chrome").Page("https://rdx-dev.rdxhub.com/workspace/patient-board").FindChild("idStr", "chk-drop-list-2", 10);
// Drag the card to the second column
cardToMove.Drag(column2);
}
I was able to achieve the drag functionality using the following function that was shared by someone else in the community.
function dragCalculatedDistance() {
startObject = Aliases.pageEmailAnalyticsGettingStarted.workspace_FirstEmail_Val
destinationObject = Aliases.pageEmailAnalyticsGettingStarted.FindElement("//li[contains(.,'My Private Folder')]")
var startPoint, targetPoint, dragX, dragY;
// Drag from the center of object A to the center of object B
// destinationObject.Click()startPoint = startObject.WindowToScreen(startObject.scrollWidth /2, startObject.scrollHeight /2);
targetPoint = destinationObject.WindowToScreen(destinationObject.scrollWidth/2, destinationObject.scrollHeight /2);dragX = targetPoint.X - startPoint.X+50;
dragY = targetPoint.Y - startPoint.Y-80;//Note the +50 and -80 is something I used to make sure the coordinates can adjust and move to the object correctly.
startObject.Drag(-1, -1, dragX, dragY);
}
Let me know if this helps.
The coding provided by tristaanogre will work fine when moving the object horizontally, on any screen size. It's best to use the function and pass in the parameters for column 1 (source) and column 2 (destination).
I only suggested Keyword Testing, as I wasn't sure whether the correct method should be Drag or Move. You'll have more control with scripting, so I suggest to stick with that 🙂
Another approach, depending on whether your web application is JavaScript, is to use removeChild() and appendChild(). For example,
Which moves the child object "img_w3slogo.gif" from parent 1 "div1" to parent 2 "div2".