Forum Discussion
Methods Advanced View too, please? scrollIntoView is not a "Standard" method or an Action.
I THINK I might know what's going on but I'm not sure... it has to do with finding objects by xPath... you're not necessarily going to find exactly the object that is an onscreen component which means it might not fully support everything that would typically be supported.
What if you change that link where you're calling "Click" to assign the result of the "find" to a variable. Drop a breakpoint then, in your code, and investigate that result to see what it actually returns.
Attached the advanced property which does say it supports scrollintoview.
The xPath i use only finds the one object on the page which is unique.
You think finding it by class or another way may work?
- tristaanogre7 years agoEsteemed Contributor
What is "ConvertToObject" doing? If you're using FindChild, the parameter buttonText needs to be a string, not an object.
Try just the following. Let's not get any fancier than we need to.
function ClickByButtonText() { var buttonVisibleText = "VALIDATE" Sys.Browser("*").Page("*").Wait("10000"); var page = Sys.Browser("*").Page("*") var mybutton = page.FindChild("contentText", buttonText, 500) if (myButton.Exists){ myButton.scrollIntoView(true); myButton.Click(); } } - tristaanogre7 years agoEsteemed Contributor
As mentioned above, finding via xPath returns not a TestComplete object which put all sorts of wrappers and such around it but the straight DOM object from the page... so the result of FindChildByXPath may find the correct object... but it's not an object with everything exposed as you would with a straight FindChild or with a mapped object.
If you use FindChild, you might have better luck.
- endorium7 years agoFrequent Contributor
Still trying. Its becoming very frustrating
Tried the below to find and click the button validate. Again if not visible on screen it does not work. If its visible it does work. If I add the scrollintoview again it says it is not supported. Surely such a simple thing cannot be this difficult? Imust be missing something simple?
function ClickByButtonText(/*buttonVisibleText*/)
{
var buttonVisibleText = "VALIDATE"
/* convert String to object */
var buttonText = ConvertToObject(buttonVisibleText);
//Waits upto 10 seconds for page to load
Sys.Browser("*").Page("*").Wait("10000");
waitUntilObjectIsVisible("//button[contains(text(),'" + buttonText + "')]");
var page = Sys.Browser("*").Page("*")
page.FindChild("contentText", buttonText, 500).Click();
}