azakharov
12 years agoContributor
Wait for element
Hi all,
Is there a way to reavaluate xpath or css element by using an existant variable already asigned to it?
For example why this one doesn't work (JScript):
var element = page.FindChildByXPath("//div[text()='A 08012012 template']"); // element is not loaded on the page yet. It needs few seconds to appear on the page
aqUtils.Delay(10000); //make a pause
element; // call for variable with xpath again
element.Click(); // returns error even if element is loaded
But this works:
var element = page.FindChildByXPath("//div[text()='A 08012012 template']");
aqUtils.Delay(10000);
var element = page.FindChildByXPath("//div[text()='A 08012012 template']"); // declare element again
element.Click(); // now it works
Why do I have to declare element again even if I have already declared it earlier?
Is there a method that does that, something like element.TryAgain()?
I want to write a reliable function that takes any css/xpath object and only allows script to proceed when it is loaded. This way I will only need to write it once and reuse it evertime I need it later.
Thanks.
Is there a way to reavaluate xpath or css element by using an existant variable already asigned to it?
For example why this one doesn't work (JScript):
var element = page.FindChildByXPath("//div[text()='A 08012012 template']"); // element is not loaded on the page yet. It needs few seconds to appear on the page
aqUtils.Delay(10000); //make a pause
element; // call for variable with xpath again
element.Click(); // returns error even if element is loaded
But this works:
var element = page.FindChildByXPath("//div[text()='A 08012012 template']");
aqUtils.Delay(10000);
var element = page.FindChildByXPath("//div[text()='A 08012012 template']"); // declare element again
element.Click(); // now it works
Why do I have to declare element again even if I have already declared it earlier?
Is there a method that does that, something like element.TryAgain()?
I want to write a reliable function that takes any css/xpath object and only allows script to proceed when it is loaded. This way I will only need to write it once and reuse it evertime I need it later.
Thanks.