not able to use Drag method
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
not able to use Drag method
Hi,
I am trying to drag and drop an item from one panel to another. When i record and play the script, it works fine. But when i try to use the Drag method in my script (using javascript), it says Drag is not a function. What is possible wrong here ?
Record script -
let page = Aliases.pageShoppingPortal;
page.panel.Drag(134, 23, 26, 182);
Javascript -
let memberdrag = page.contentDocument.getElementsByClassName("name cdk-drag");
memberdrag.item(1).Drag(134, 23, 26, 182);
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As per documentation, the Depth parameter for the .Find() method (the third one ) must be positive integer.
Try to change -1 to some big value.
Quote from the documentation:
"Depth
An integer number that specifies the level of objects where Find will search for the desired object. If Depth is less than or equal to 0, it means that the method will search only in testObj. If Depth is 1 (default), Find will search in testObj and its child objects, if Depth is 2, Find will search in testObj and its child and grandchild objects, and so on. To search in the whole testObj hierarchy, use a Depth value that is greater than the number of child levels in the hierarchy, for example, 20000."
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Alex,
Yeah ! i tried increasing the depth. That ways, i don't get the invalid parameter error as before.
But, still it is not able to find memberdragFrom and memberdragTo. It says - object cannot be found..
Is their any other approach i can follow ?
Thanks for your patience.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI,
> That ways, i don't get the invalid parameter error as before.
Great.
> It says - object cannot be found
Can you provide your code? What recognition parameters do you use?
Mine were provided as an illustration only. You need to investigate actual objects in the Object Browser, choose those that uniquely and stably can identify the objects that you need and use their names and values as the recognition parameters.
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the code I am using ---
function Drag_Smartbear(){
let page = Sys.Browser("*").Page("*");
memberdragFrom = page.Find(new Array("class", "index"), new Array("name cdk-drag", 1), 20000);
memberdragTo = page.Find(new Array("class", "index"), new Array("*dragHere*", 2), 20000);
Log.Message(memberdragFrom)
Log.Message(memberdragTo)
if (!(memberdragFrom.Exists && memberdragTo.Exists)){
Log.Message("cannot be dragged")
}else {
Log.Message("Yay ! cann be dragged")
}
let toX = memberdragFrom.Left - memberdragTo.Left +memberdragTo.Width / 2;
Log.Message(toX);
let toY = memberdragFrom.Top - memberdragTo.Top +memberdragTo.Height / 2;
Log.Message(toY);
memberdragFrom.Drag (memberdragFrom.Width / 2, memberdragFrom.Height / 2, toX, toY, skNoShift);
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> memberdragFrom = page.Find(new Array("class", "index"), new Array("name cdk-drag", 1), 20000);
> memberdragTo = page.Find(new Array("class", "index"), new Array("*dragHere*", 2), 20000);
Have you checked that the class name of the first sought for element is exactly "name cdk-drag" and that the class name of the second element contains the text "dragHere" ?
Also, does the value of the index property for the first element equals to one and the value of the index property for the second element equals to two?
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes Alex. Both class names and index are correct. I have re-verified.
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
What about the parameters for memberdragTo ?
What line of your code throws the error? What is exact text of the error and what is the content of the corresponding Details log pane?
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alex,
I have verified for memberdragTo too.. It is fine.
The error is thrown at this line :
let toX = memberdragFrom.Left - memberdragTo.Left +memberdragTo.Width / 2;
and the error says -
memberdragTo = page.Find(new Array("class", "index"), new Array("*dragHere*", 2), 20000);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> So, it clearly depicts that test complete is not able to recognize
The error message means not that TestComplete cannot recognize, but that TestComplete cannot find web element that match provided search criteria.
You must examine the elements that you need to find in the Object Browser and identify a set of stable and unique properties that make it possible to find the elements that you are looking for.
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »