Sencha test timeout, waiting - javascript

I'm starting with Sencha test and trying run some simple tests.
I start with simple webpage and it works. Now when I create simple form i ext, and try to test it using localhost, I have communicate
Failed: Timeout waiting for target (input[name="name"]) to be available
I'm doing it exactly same way just change the elements names, so it should work.
I know that it can be cos page loading is too long so I try add function for wait (both with time and until it find element), nothing helps.
Any ideas?

Related

Protractor automation:scripts is waiting longer time to execute between the steps

I executed the protractor automation scripts.
After executing the some few lines. script is idle for x seconds(approx 150 sec) and not going to the next line. Every time its happening at the same line
This is scripts was running perfectly in the older version of application. In the newer version i am facing the issue.
Check manually if you see the same issue if not please post html and the script. You should go step by step and check all locators - maybe html was changed.

Strategy for selenium-webdriver in javascript for testing in different environments

I've been making a functional tests using selenium-webdriver using yadda library. The problem it's that in my different environments the same test suite working different. Example:
On tests, the result it's different based on the environment that I entry.
Local localhost:5000
Open my search site
․ when i go to my site: 2169ms
․ when i write a text on the search input: 21ms
․ when i click the search button: 130ms
․ then i get the results page.": 46ms
Staging mystaging.domain.com
Open my search site:
StaleElementReferenceError: {"errorMessage":"Element is no longer attached to the DOM","request":{"headers":{"Accept":"application/json; charset=utf-8","Connection":"close","Content-Length":"2"
Production www.domain.com
Open my search site
․ when i go to my site: 2169ms
․ when i write a text on the search input: 21ms
․ when i click the search button: 130ms
․ then i get the results page.": 46ms
At this time, only the staging tests are failing, but in other situations when the internet connection it's slow, the tests fails in production but pass in staging.
The main problem it's that the browser doesn't have the DOM ready for the test and they doesn't find the element required for the test.
My approach for trying to solve this, it's wait that appear the root element of my page like this:
return driver.wait(() => driver.isElementPresent(By.css(".my__homepage")), 50000);
But this isn't enough for me, because the test suites are still failing randomly.So, my question it's:
Which could be a best approach for run in different environments the tests suite dealing with the elements that isn't ready on the browser ?
I am showing you a simple C# code which I did for my work in IE browser but it can work similarly for other browsers and languages.
private static WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(120)); //max driver wait timeout 120 seconds
try
{
//waiting for document to be ready
IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)driver;
wait.Until(sc => jsExecutor.ExecuteScript("return document.readyState").Equals("complete"));
//waiting for an element.
//use 'ExpectedConditions.ElementToBeClickable' as in some cases element gets loaded but might not be still ready to be clicked
wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("elementID")));
}
catch (Exception ex)
{
}
Basically I am putting a wait for the document to be ready using JavaScript executor
Also I am putting an implicit wait for each element that I would access. I am using expected condition as ElementToBeClickable because sometime ElementIsPresent does not mean element can be accessed as per your needs.
Note: Addiotinally you might also have to check for other element properties (like enabled/disabled, etc) depending on your needs.

Is there a way to have a web application continue running even when it is closed?

Suppose I want to build someone similar to an alarm, except every hour it performs a list of tasks. For the sake of this example, suppose it is to send notifications. I want the inner function to look something like this:
$scope.performTasks = function(){
emailUserWeb();
emailUserPhone();
postToFacebook();
postToTwitter();
postToWherever();
}
So, assume everyday, this sends a notification at exactly ##:37pm. If I want something like this to run even when I am not on the site, how can I build something like that? Is it even possible?
Your Javascript is client-sided. That means it can only be executed as long as it is executed by the client's browser.
If you want to execute scheduled tasks, you need a server that runs the code (e.g., NodeJS).
You can build it as Chrome App/Extension which will have a backgroud process, If you keep Chrome running, even if not on the app webpage, it will work.
Check: https://developer.chrome.com/extensions/background_pages

Angular Protractor tests fail with Select2 inside Modal

I’m trying to run my angular e2e tests with protractor. I’ve got some situations where a select exists inside a modal. Depending on the machine running the tests, this sometimes fails as protractor can’t find the select with:
NoSuchElementError: No element found using locator: By.cssSelector("div#s2id_items”)
On a slower machine this works every time, while on faster machines it often fails. My guess is that the modal is still being animated when protractor tries to access the selector, hence, resulting in failure.
I’ve tried to disable animations without success with the code bellow inside the onPrepare directive in my protractor config:
var disableNgAnimate = function() {
angular.module('disableNgAnimate', []).run(['$animate', function($animate) {
$animate.enabled(false);
}]);
};
browser.addMockModule('disableNgAnimate',disableNgAnimate);
I’m using angular 1.4.3 with bootstrap 3.3.5 and protractor 2.1.0.
Thanks
Edit:
1 - I'm not using explicit waits and I wouldn't like to, as these would either considerably slow down tests or still be prone to failure in some scenarios.
You could try using Expected Conditions for wait, such as:
var EC = protractor.ExpectedConditions;
var myElement= element(by.css('div#s2id_items'));
browser.wait(EC.presenceOf(myElement), 5000);
//rest of your code
This wait will not slow down your tests, as it will only wait long enough for the element to be shown, and fail after 5 sec if it isn't.
EDIT: For clickable, animated objects you can either try built-in "elementToBeClickable" condition (just replace presenceOf in the above example), or write your own, that would do whatever you like (function returning true of false). E2E tests should "think" as a user would, and a user would wait for the animation to end, so maybe it would be best if you used explicit wait for the animation after all.

Using setTimeout in extension for Selenium IDE

I'm trying to use JavaScript's setTimeout in an extension I've made for Selenium IDE.
In short I have made the extension to take a username and password to login to a page, rather than having to use a few commands on every test I make, it'd save a lot of time using my custom command.
So obviously In need to wait for the page to load, so I have added a setTimeout which calls a function that will keep checking if the page is ready yet.
setTimeout only seems to run the once however.
Thinking I may have something wrong with my script I just copied some off w3schools and that fails to work either, so tried this simple one below, which surely should work, but I only get a log output of '1'.
var i=0;
function loopThrough(){
i=i+1;
LOG.info(i);
setTimeout("loopThrough()", 2500);
}
loopThrough();

Categories