PDA

View Full Version : Timeout waiting for target to be available for ST.future.Element



Rohan Jalil
8 Mar 2017, 6:08 AM
Hello guys,

I am facing a problem with sencha test. Here is the problem

I run my test and a page open which has two button and by click any of the button the user is directed to his or her home page. Now on the homepage we have a button. I'm trying to click that button but the problem is it is throwing me this error

Timeout waiting for target to be available for ST.future.Element

Can you please help me out. Here is the code



describe("invigos Student Clicked", function() {
it("Larare Button Clicked", function() {
var a = ST.element('#btnStudent')
.click(10, 10)
.wait(30000)
.and(function(stButton){
expect(stButton).toBeTruthy();
alert('Student button clicked');
debugger;
ST.element("#studentJoinAssignmentButton")
.click(10, 10).wait(10000)
.and(function(el){
debugger;
alert('abcd');
});
});

});

});


When ever I run this code I do not see any click happening and it does not comes in the and function


and one thing more how will I know that ST.element('#someId') has returned me a valid element

Please help me out. Thanks

craigcomstock
9 Mar 2017, 8:38 AM
If you only do ST.element('#btnStudent') does the test pass? Is #btnStudent the component ID of an Ext Button? Maybe you should use an element ID as '@btnStudent'? Here is some reference for what can be used as a locator string:

http://docs.sencha.com/sencha_test/2.0.2/api/ST.Locator.html

Rohan Jalil
9 Mar 2017, 11:23 PM
Thanks a lot for your responce

yes #btnStudent is the ID of Ext Button, and yes it does pass when we only try



describe("invigos Student Clicked", function() {
it("Larare Button Clicked", function() {
var a = ST.element('#btnStudent')
.click(10, 10)
.and(function(){
alert('hi');
})
});
});


and same like #btnStudent, #studentJoinAssignmentButton is also an id of Ext Button, available on next page

Rohan Jalil
20 Mar 2017, 12:04 AM
I did increase the timeout time too but same thing,
It opens the required page but can't find the required button captured by Event Recorder

Rohan Jalil
27 Mar 2017, 3:15 AM
Hi,
Will you please help me.?
Thanks

craigcomstock
27 Mar 2017, 7:36 AM
When it navigates to the required page did you open dev tools on the browser and try to locate the element via ST.find()? This function uses the same syntax for a locator as the ST futures API does.

The procedure roughly would be:


describe("invigos Student Clicked", function() {
it("Larare Button Clicked", function() {
var a = ST.element('#btnStudent')
.click(10, 10)
.and(function(){
debugger // this should pause Sencha Studio so that you can open dev tools in the target browser
// and run commands like ST.find('#btnStudent') and examine the elements in the page etc...
alert('hi');
})
});
});

Rohan Jalil
28 Mar 2017, 11:15 PM
Hi,
When i put a debugger as you suggested, and try to find #btnStudent it works, it return me the button with its id, text style etc

But when i pit a send an el in and function like .and(function(el){ }))
it shows me that el is a button . But the functions like .getUrl and .navigate() are not working with it.

And when i put a wait then it doesn't stop on debugger


describe("invigos Student Clicked", function() {
it("Larare Button Clicked", function() {
var a = ST.element('#btnStudent')
.click(10, 10).wait(2000)

.and(function(){
debugger

alert('hi');
})
});
});





because i want a little wait here so it renders to the next page where i can find #studentJoinAssignmentButton .
Thanks for response

craigcomstock
29 Mar 2017, 7:33 AM
Depending on whether you are using a WebDriver or In-Browser scenario the values will differ... see the explanation/docs here:

http://docs.sencha.com/sencha_test/2.0.2/api/ST.future.Element.html#method-and

"The future's value is passed as the first argument. For an Element future the arg will be an ST.Element (http://docs.sencha.com/sencha_test/2.0.2/api/ST.Element.html), for components it will be various things, typically the component instance itself. If the scenario is a WebDriver scenario the arg will be the current future such as ST.future.Element above."

So this tells me that you are running In-Browser. If this is the case and you're script navigates to a different URL then the test will fail as you describe. You must change your scenario to a WebDriver type in the Advanced Section of the Scenario settings. The selected item is darker in color as below:

56094


If you don't see the Test Type options then you need to change a General setting... with the upper-right gear icon in Studio.

56092

Then check the General tab and Role:. Make sure that Developer is selected (darker color).

56093

The online docs in this area are in the process of being updated so don't reflect this change.