asynchronous script timeout - angularjs

I am new to protractor & using Protractor-net. Getting an "Asynchronous script timeout: result not received in 0 seconds" exception when running Protractor-net scripts.
https://github.com/bbaia/protractor-net
Does this mean the parameter passing to identify angular element is wrong?
Found this solution to solve this -
https://github.com/angular/protractor/issues/117
How do I achieve the same in protractor-net?

You need to set async timeout to increase the timeout if you don't want it to be 0 and do it wherever the driver is instantiated.
It is particularly essential due to the nature of Angular's asynchronous behavior.
[SetUp]
public void SetUp()
{
//driver = new PhantomJSDriver();
driver = new ChromeDriver();
//SetScriptTimeout is the asysn script timeout
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));
}
See this

Related

Jmeter webdriver wait funtion - Can not create new object with constructor org.openqa.selenium.support.ui.WebDriverWait with the passed arguments

I am trying to use the JMeter Selenium Webdriver wait function but getting error output as -javax.script.ScriptException: TypeError: Can not create new object with constructor org.openqa.selenium.support.ui.WebDriverWait with the passed arguments; they do not match any of its method signatures. in at line number 2
var ui = JavaImporter(org.openqa.selenium.support.ui)
var wait = new ui.WebDriverWait(WDS.browser,120)
Code in the webdriver sampler:
var ui = JavaImporter(org.openqa.selenium.support.ui)
var wait = new ui.WebDriverWait(WDS.browser,120)
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
WDS.sampleResult.sampleEnd()
I am using the latest version of Jmeter (5.5) and the latest selenium webdriver support package (4.5.1). This use to work before. Can someone help here please? thanks!!
I have tried upgrading and degrading the Jmeter, but no luck.
WebDriver Sampler 4.5.1 comes bundled with selenium-support 4.5.0 and WebDriverWait constructor for this version expects 2nd argument to be Duration object
So you need to do something like:
var wait = new ui.WebDriverWait(WDS.browser, java.time.Duration.ofSeconds(120))
Also be informed that since JMeter 3.1 it's recommended to use Groovy language for scripting mainly for performance reasons so you might want consider switching, it would be way easier to debug your test.

Timeout for AndroidJUnitRunner + ActivityInstrumentationTestCase2?

The setup:
An older project I've inherited has a lot of legacy instrumentation tests and I would like to impose a timeout on them, since a lot of them can hang indefinitely and this makes it hard to get a test report. I'm in the process of updating the tests to be Junit4 style, but at the moment they're all extending ActivityInstrumentationTestCase2.
Tried so far:
In the documentation for AndroidJUnitRunner it says to set this flag:
Set timeout (in milliseconds) that will be applied to each test: -e timeout_msec 5000
...
...
All arguments can also be specified in the in the AndroidManifest via a meta-data tag
I've tried adding AndroidJUnitRunner configuration to the app manifest and the test manifest, but the timeout_msec meta-data item has had no effect so far.
You can use a rule to provide a timeout for each test in the class as shown below.
#Rule public Timeout timeout = new Timeout(120000, TimeUnit.MILLISECONDS);
You can also specify per test basis timeouts by using the following
#Test(timeout = 100) // Exception: test timed out after 100 milliseconds
public void test1() throws Exception {
Thread.sleep(200);
}
You can read more about the differences using this link
https://stackoverflow.com/a/32034936/2128442

How can I create a webdriverjs promise without creating a webdriver instance?

I need to do some node require commands in a webdriverJS test script, because these dont get entered into the webdriverJS command queue, I am wrapping them in .then() functions (to deal with the asyncrony)
e.g.
var webdriver = require('selenium-webdriver');
// create webdriver instance so promise chain can be setup
var promise_builder = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).
build();
// wrap all functions in webdriver promises so they get managed by webdrivers
// command queue
promise_builder.sleep(0).then(function() {
// Run "non-command-queue" commands
var tests = require('./test_commands');
tests(helpers, setup, webdriver, driver);
}).then(function(){
// more non-webdriver commands
});
The problem here (other than the fact its inelegant) is that a browser instance is launched - just to achieve promise chaining.
Is there a better way to create the initial promise, e.g. a static method within the webdriver api for creating promises?
This seems to work:
// create an instance of webdriver.promise.ControlFlow
var flow = webdriver.promise.controlFlow();
// use webdriver.promise.controlFlow#execute() to schedule statements into command queue
flow.execute(function() {
// Run "non-command-queue" commands
var tests = require('./test_commands');
tests(helpers, setup, webdriver, driver);
}).then(function(){
// more non-webdriver commands
});
An explantion can be found on this Webdriver JS website/docs site, i.e.
At the heart of the promise manager is the ControlFlow class. You can obtain an instance of this class using webdriver.promise.controlFlow(). Tasks are enqueued using the execute() function. Tasks always execute in a future turn of the event loop, once those before it in the queue (if there are any) have completed.
I would use webdriver.promise.createFlow(callback) to start a new control flow.
So you'd have something like this:
webdriver.promise.createFlow(function() {
// Run "non-command-queue" commands
var tests = require('./test_commands');
tests(helpers, setup, webdriver, driver);
}).then(function(){
// more non-webdriver commands
});
Documentation: http://selenium.googlecode.com/git/docs/api/javascript/namespace_webdriver_promise.html
Update
I am now leaning towards the webdriver.promise.controlFlow.execute() option that #the_velour_fog described, since I get errors with after hook failing when new controlFlow is created. Guess creating a new flow messes with mocha async functionality.

Script hangs because page loads too quickly?

I am seeing a problem with either Robot Framework or Selenium Webdriver in cases where a link or element is clicked that results in a page transition. The script hangs & stops running as if it's trying & failing to click the requested element/link even though the window successfully processed the click. Manually refreshing the Webdriver window to reload the page kick-starts the script and it resumes from there.
The only thing I can think is there is a delay between when Selenium or Robot executes the command and when it's able to listen for an HTTP response from the browser, and the page is loading before Selenium is ready to listen for it. This is running on an intranet and so the page load times are pretty quick. I've never seen the issue happen when running the same script on a SauceLabs VM since the tunnel between us & them adds a lot of latency.
Assuming my theory is correct, what do I do about it (apart from the obvious running over a slower connection)? Setting a delay in Selenium only slows down the execution and doesn't really affect the problem.
You can try fluent wait...
public static WebElement fluentWait(final By locator, RemoteWebDriver rwd){
Wait<WebDriver> wait = new FluentWait<WebDriver>(rwd)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(
new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}
);
return foo;
};
This will poll every 2 seconds and wait a maximum of 30 seconds
in your Test you then wait for an element eg fluentWait(By.className("home"), driver);
before you can click or verify text etc
Try:
Set Selenium Implicit Wait 60
Set Browser Implicit Wait 60
The number 60 is the seconds to wait by default for both selenium/browser.

Silverlight 4 WCF RIA Service Timeout Problem

I have a Silverlight 4 usercontrol that calls a very long running WCF RIA service. As shown below, I am increasing the default timeout period.
_domainContext = new WindowsDashboardDomainContext();
// Increase timeout -- this can be a very long running query
((WebDomainClient<WindowsDashboardDomainContext.IWindowsDashboardDomainServiceContract>)
_domainContext.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(99, 0, 0);
_domainContext.GetSections( "All", "All", "All" ).Completed += GetAllSectionsCompleted;
Unfortunately, it seems to ignore this timeout and still throws the timeout exception:
Error: Unhandled Error in Silverlight Application Load operation failed for query 'GetClicks'. An error occurred while executing the command definition. See the inner exception for details. Inner exception message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
Why is this happening?
I answered the same question here: WCF ria service SP1 timeout expired
The answer:
I'll explain my context and I wish it will work for my. I'm sure about that.
First of all to call RIA services, and using some domain context, in my example:
EmployeeDomainContext context = new EmployeeDomainContext();
InvokeOperation<bool> invokeOperation = context.GenerateTMEAccessByEmployee(1, 'Bob');
invokeOperation.Completed += (s, x) =>
{....};
Nothing new until here. And with this I was facing every time that same timeout exception after 1 minute. I spend quite a lot of time trying to face how to change the timeout definition, I tried all possible changes in Web.config and nothing. The solution was:
Create a CustomEmployeeDomainContext, that is a partial class localizated in the same path of the generated code and this class use the hook method OnCreate to change the behavior of created domain context. In this class you should wrote:
public partial class EmployeeDomainContext : DomainContext
{
partial void OnCreated()
{
PropertyInfo channelFactoryProperty = this.DomainClient.GetType().GetProperty("ChannelFactory");
if (channelFactoryProperty == null)
{
throw new InvalidOperationException(
"There is no 'ChannelFactory' property on the DomainClient.");
}
ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(this.DomainClient, null);
factory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 10, 0);
}
}
I looking forward for you feedback.
There are two possibilities that come to mind:
You have not configured your DomainService to serilalize enough objects. The default is very small. Try this tip I put in yesterday to increase the resultset allocation
Your data source may be timing out. In that case you need to increase the command timeout for LINQ to SQL, EF, or ADO.NET accordingly. This is the less likely cause, but one to consider.

Resources