Nightwatch.js using ".registerBasicAuth() results into error - basic-authentication

When using something like:
browser
.registerBasicAuth('admin', 'admin')
.navigateTo('http://the-internet.herokuapp.com/basic_auth')
.assert.titleContains('The Internet');
Nightwatch is throwing this error: [Error]1

Related

Problem in writing error logs to a file in R

I'd like to do some error handling in my R program. So I'm using tryCatch function and I would like to write the error message (in case there is any error to a file). Here is the code I have
basicConfig(level='INFO')
addHandler(writeToFile, file=file_name.txt, level='INFO')
tryCatch(
{
logger <- getLogger()
...
},
error=function(cond) {
logger$error(cond)
})
but it looks like cond does not contain the error message and the log file ends up as empty. How can I write down th error thread/message then?

The following error occurred: An unknown server-side error occurred while processing the command, on Browsestack

Script failing on Browserstack (intermittently).
Using serenity-bdd , and executing on browserstack....
DesiredCapabilities capabilities = new DesiredCapabilities();
if (MyDriverClass.deviceType.equalsIgnoreCase("Tablet")) {
capabilities.setCapability("os_version", "8.0");
capabilities.setCapability("device", "Samsung Galaxy Tab S3");
capabilities.setCapability("real_mobile", "true");
capabilities.setCapability("browserstack.platform",
"ANDROID");
capabilities.setCapability("project", "Tablet_PROJECT");
capabilities.setCapability("browserstack.browser", "chrome");
capabilities.setCapability("browserstack.browser_version", "76.0");
//also used appium version 1.6.5
capabilities.setCapability("browserstack.appium_version", "1.7.1");
capabilities.setCapability("deviceOrientation", orientation);
capabilities.setCapability("browserstack.local", browserstackLocal);
capabilities.setCapability("browserstack.localIdentifier",
browserstackLocalIdentifier);
capabilities.setCapability("browserstack.debug", true);
capabilities.setCapability("browserstack.video", true);
capabilities.setCapability("build", browserStackTCBuild);
return new RemoteWebDriver(
new URL("https://" + username + ":" + accessKey + "#hub-
cloud.browserstack.com/wd/hub"),`enter code here`
capabilities);
I am not sure why getting server side error. Even all the script relate elements and locator is on the page and in view.
The error unknown server-side error is generally encountered when the element you are trying to locate is hidden/ not visible.
You will need to ensure that the element you are trying to locate is in the viewport and nothing is overlaying it. You can read more on the exact causes for the above error here.

HTTP.call throws errors instead of returning response

I am working with the Facebook graph API and have run into trouble regarding handling failed requests.
I use this code to create a new post
SocialFacebook.createPosting = function(data) {
var options = {
params: {
access_token : data.tokens.accessToken,
message : data.text
}
};
var url = 'https://graph.facebook.com/' + data.graphId + '/feed';
var response = HTTP.call('POST', url, options).data;
return response;
}
But instead of returning a JS object with error information in the response, it throws an error on failed requests
Exception while invoking method 'createPosting' Error: failed [500] {"error":{"message":"Duplicate status message","type":"FacebookApiException","code":506,"error_subcode":1455006,"is_transient":false,"error_user_title":"Duplicate Status Update","error_user_msg":"This status update is identical to the last one you posted. Try posting something different, or delete your previous update."}}
Because it's wrapped in an Error, the otherwise JSON object is now a string with some other stuff appended to it, which makes it difficult to parse and extract the attributes
Any idea as to why it throws an error, instead of returning a JS object with error details like usually?
Much appreciated
According to the docs, about HTTP.call():
On the server, this function can be run either synchronously or asynchronously. If the callback is omitted, it runs synchronously and the results are returned once the request completes successfully. If the request was not successful, an error is thrown.
So there you have it: since you called HTTP.call() synchronously (without providing a callback), if it responds with an error (in your case, Code 500) the error is thrown and not included in the data.

Create Custom Json Error in Asp.NET MVC

I am using a JavaScript plug-in and if there is an error it expects format like;
{error: 'You are not allowed to upload such a file.'}
In my MVC Web API I am throwing error like;
var error = string.Format("An error has been occured. Please try again later.");
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, error));
and it is represented in HTTP response like below;
{"Message":"An error has been occured. Please try again later."}
how can I achieve to return in first way?
You can create an anonymous object
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError,new { error = "your error message here!"}));

phpunit fail message for wrong exception thrown

I'm using phpunit for TDD approach. Currently, some tests I've already written fail, because I'm waiting for other people to catch up with my tests. Therefore, I want to print out a failed assertion message for each assertion that fails now, e.g.
$this->assertTrue($now_its_false, '> my friend should fix method X to return Y');
This works for standard assertions, but I can't figure out how to print such message when testing exceptions. For example, I've test a method that should raise an exception, but it doesn't. My code looks like this:
public function testSomethingIncorrect() {
$this->setExpectedException('SomeException');
$object->doSomethingThatShouldRaiseException();
$this->fail('This call should raise exception!');
}
How to print out the test fail message here?
There is no "clear" way to achieve this. You can notice that PHPUnit_Framework_Constraint_Exception doesn't take any description argument.
Anyway you can do it "around".
try {
$object->doSomethingThatShouldRaiseException();
$this->fail('This call should raise exception!');
} catch ('SomeException') {
}

Resources