Forum Discussion
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?
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.
- 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(); } } - 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();
}