Element is present but nightwatch.js not seeing element - selenium

So i've been experimenting with NW and have found it is KISS(Keep It Stupid Simple)! I have ran into one problem though.
I am a freelance QA tester that has focused primarily on manual testing, however i'm branching out to automation to help speed up tasks at work.
The site i am currently testing has "2" steps when you navigate to it. The structure is as follows:
1: Navigate to URL
2: "subscribe page" displays containing a box to enter your email
3: Once email is enter, box changes to have user to enter their zipcode
When users are on the email section, if the email is not syntactically valid, it will contain a little X icon, if its valid, it contains a checkmark
The same is true for the zipcode section.
What am I testing:
Both the invalid and valid icons for both the email and zip code display when they should.
I've broken my tests up into two segments. 1 for testing the email address icons, and 1 for testing the zip icons.
I've gotten the email address tests written and they run perfectly, however the zip address keeps failing out for me.
Here is a block of code that i'm using for the zip code.
When running, i'm seeing:
✔ Element <#two_step_div> was present after 985 milliseconds.
✔ Testing if the page title equals "WEBSITE TITLE HERE".
✔ Element <#postal_code> was present after 14 milliseconds.s
✖ Timed out while waiting for element <input[class="js-zip js-success"]> to be present for 10000 milliseconds. - expected "visible" but got: not found
'This is checking valid zip icon is present': function (browser) {
browser
.url("WEBSITE_URL HERE")
.waitForElementPresent("#two_step_div", 8000)
.assert.title('WEBSITE TITLE HERE')
.setValue('input[type=text]', ['test#example.com', browser.Keys.ENTER])
.waitForElementPresent("#postal_code", 10000)
.setValue('input[type=text]', '12345')
.waitForElementVisible('input[class="js-zip js-success"]', 10000)
.end();
};
It seems like its just skipping over the .setValue line as it doesn't even seem like its adding the "12345" zipcode that i'm specifyings.
Any ideas?

'This is checking valid zip icon is present': function (browser) {
browser
.url("WEBSITE_URL HERE")
.waitForElementPresent("#two_step_div", 8000)
.assert.title('WEBSITE TITLE HERE')
.setValue('input[type=text]', ['test#example.com', browser.Keys.ENTER])
.waitForElementPresent("#postal_code", 10000)
.setValue('#postal_code', '12345')
.waitForElementVisible('input[class="js-zip js-success"]', 10000)
.end();
};

Related

Twilio mobile number verification - VerificationCheck was not found on Express

The requested resource /Services/serviceSSID/VerificationCheck was not found is the eroor showing in the console
my code is
otpLogin:async (req,res)=>{
console.log(req.body.otp);
try {
const isOTP = await client.verify.services(serviceSSID).verificationChecks.create({
to:`+91${req.body.phone}`,
code:req.body.otp
})
if(isOTP)console.log(isOTP);
return res.status(200).json({message:" mobile number verified"})
} catch (error) {
console.log(error.message)
return res.status(500).json({message:"something went wrong"})
}
}
Twilio developer evangelist here.
From the documentation:
Twilio deletes the verification SID once it’s:
expired (10 minutes)
approved
when the max attempts to check a code have been reached
If any of these occur, verification checks will return a 404 not found error like this:
Unable to create record: The requested resource /Services/VAXXXXXXXXXXXXX/VerificationCheck was not found
If you’d like to double check what happened with a given verification - please use the logs found in the Twilio Console under your Verification Service:
I've found that if you submit a form twice by clicking a submit button twice quickly, that the verification is successfully checked and then because it was a success deleted, then the second check fails with a 404 like this and that is the error result you see. To avoid this, you should stop users from being able to submit the form twice by disabling the submit button after the first attempt.
I can confirm that philnash 2nd statement is correct. However wouldn't it have been handled way better if instead we just get a response from client.verify.services(serviceSSID).verificationChecks that the 2nd (and so on checks) failed??

Asp.Net returning 404 status code, displays empty / blank page in mozilla firefox

When I an returning 404 status code in Asp.Net Core API project.
It works fine with chrome but, shows blank page in mozilla firefox instead of 404 error page, like in other browsers.
Sample Code for my API is below:
[HttpGet]
[Route("OpenBlobFile", Name = "url")]
public async Task<ActionResult> OpenBlobFile(string fileName, string folder)
{
return new NotFoundObjectResult(null);
}
enter image description here
I got my answer from here: https://forums.asp.net/t/1384390.aspx?Returning+404+from+controller+displays+empty+page+in+firefox
Conclusion:
Firefox does not have a native error page, like in other browsers.
Yes. Chrome and IE behave normally and display the corresponding default error page, while Firefox believes it is best to display a blank page.
Therefore, in most cases, Firefox will not display a generic 404 error page.
You need to use these if you want just a 404 error
return StatusCode(404);
return new StatusCodeResult(404);
Any of these won't, as they add either the id or an object to the response's body
return StatusCode(404, 123);
return StatusCode(404, new { id = 123 });
return new NotFoundObjectResult(123);

How to create "Round Robin Call Forwarding Function" in Twilio Stack

I have researched high and low through multiple websites and have not found a single fully documented solution for round-robin call forwarding with-in the Twilio stack; let alone within Twilio Studio. The last time this question was asked in detail was in 2013 so your help is greatly appreciated. I am looking to find a solution to the following to educate myself and others:
[Round Robin Scenario]
Mentioned by Phil Krnjeu on Aug 1 '13 at 23:04, "I'm trying to create a website that has a phone number on it (say, a phone number for a school). When you call that number, it has different secretary offices (A,B,C, D). I want to create something where the main number is called, and then it goes and calls phone number A the first time, the second time someone calls the main number, number B is called, C, then D. Once D is called (which would be the 4th call), the 5th call goes back to A."
The response to the above question was to use an IVR Screening & Recording application which requires the caller to pick an agent which is not a true Round Robin solution. The solution I am looking for and many others require the system to know which agent is in a group and which agent is next to receive a call.
[Key Features Needed]
Ability to add forwarding numbers as identified above A, B, C, D as a group or IVR extensions such as 1 = Management, 2 = Sales and etc...
Set a subsequent calling rule that notates in a DB of some sort. Caller A through D, for example, equals 1 unsuccessful. When caller A has been forwarded a call it now equals 0 successful then the script stops and allows the call to be answered by the user or its voicemail. Then the next call comes in and is forwarded to user B and assigned a 0 successful value, then the script stops.
After the caller finishes the call or finishes leaving a voicemail the script needs to end the call.
[Final Destination]
The round-robin should finalize its call with the forwarded phone numbers voicemail.
[Known Issues]
Forwarding a call to multiple numbers not stopping when someone answers
[Options]
Once this question is posted I am sure someone will ask in the near future what if I wanted the call to be forwarded to a Twilio voicemail instead of using the forwarded phone number's voicemail which could be let's say a cell phone. I do not necessarily need this feature, however, making an additional comment would be very helpful to the community. Thank you for your time.
I have limited knowledge of programming besides having the ability to review articles posted by other users. One article I researched in detail that did not work for me was, "IVR: Screening & Recording with PHP and Laravel."
The solution I am looking for first would be to make this code through the new Twilio Studio interface if that is not possible then any other solution would be helpful to all.
Sam here from the Twilio Support Team. You can build what you've described using Twilio's Runtime suite, Studio, and Functions.
I wrote a blog post with detailed instructions and screenshots here, and I've included a summarized version below as well.
CREATE YOUR VARIABLE
First, you need to create a serverless Variable which will be used as the round robin counter. The variable must be inside an Environment, which is inside a Service. This is the only part of the application where you will need your own laptop. You can see how to create these with any of the SDKs or using curl in the docs.
Create a Service
Create an Environment
Create a Variable
Be sure to copy the SIDs of your Service, Environment, and Variable since you will need that for your function.
For convenience, this is how you create the Variable in NodeJS.
const accountSid = 'your_account_sid';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.serverless.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.variables
.create({key: 'key', value: 'value'})
.then(variable => console.log(variable.sid));
CREATE YOUR FUNCTION
Create the following Environment Variables here in the console and save set them equal to their respective SID that you saved earlier.
RR_SERVICE_SID
RR_ENV_SID
RR_VAR_SID_CTR
Next, make sure you check the Enable ACCOUNT_SID and AUTH_TOKEN checkbox above the Environment Variables section under Credentials.
Be sure your Twilio Client version in the Dependencies section is set to the latest, so we can be sure it includes the Serverless resources. At the time of writing (March 2020), the default Client version does not include them, so we upgraded to 3.41.1, which was the latest.
Go here in the console and create a blank Function.
Copy and paste the following code and replace the numbers with the ones you would like to include in your Round Robin (make sure the environment variables you just created match what's in the code).
exports.handler = function(context, event, callback) {
// Number List
let numbers = [
"+18652142345", //Sam
"+18651092837", //Tina
"+19193271892", //Matt
// Copy and paste line above to add another number.
];
// Initialize Twilio Client
let client = context.getTwilioClient();
// Fetch Round Robin Ctr
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.fetch()
.then(variable => {
// Use counter value to determine number to call
let number = numbers[variable.value];
// Create var with new ctr value
let ctr = variable.value;
// Check if current counter value is less than RR length (i.e. the number of numbers in round robin)
// If so, increment
if(ctr == numbers.length-1) {
ctr = 0;
}
// Otherwise reset ctr
else ctr++;
// Update counter value
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.update({value: ctr})
.then(resp => {
// Return number to call
let response = {number};
// Return our counter value and a null error value
callback(null, response);
});
});
};
CREATE YOUR STUDIO FLOW
Click the red plus sign to create a new Flow here.
Give the Flow a name and click Next.
Scroll to the bottom of the templates and click 'Import from JSON' and click Next.
Paste the Flow JSON shown here and click Next.
Click the RoundRobin function widget and select the Function you just created under the Default service.
Click the FunctionError widget, click MESSAGING & CHAT CONFIG, and change the SEND MESSAGE TO number to a number that you would like to notify by text in the event of a Function failure.
Click the DefaultNumber widget and change the default number that will be forwarded to in the event of a Function failure.
Click the Publish button at the top of your Flow.
CONFIGURE YOUR TWILIO NUMBER
Go here in the console.
Click the Twilio number you would like to configure.
Scroll down to the A CALL COMES IN dropdown in the Voice section and select Studio Flow.
Select your new Flow in the Select a Flow dropdown to the right.
Click Save at the bottom.
And that's it. You're now all set to test!

Unable to read the Content of Email Automation Anywhere

I am reading the incoming mails from a outlook mailbox using automation anywhere Email Automation - Get All Messages menu. My simple code is given below. But everytime I am getting html objects and tags printing in the message box, I want only the email message.
Start Loop "Each message on server:outlook.office.365.com,User Name:xyz#xyz.com,SSL Server Type:POP3,Message Format:Plain Text"
Message Box:"$Email Message$"
Can anyone help????
In your original Email Automation - Get All Messages command, there should be a "Message Format" option below port number.
If not - you could offload to a javascript script that might look like this and call it via Run Script:
function noTags(vString) {
return vString.replace(/<(.|\n)*?>/g, '');
}
Passing vString into it and getting vString back out, now without the tags.

Docpad : show error/success message on contact form

I added a route in my docpad.coffee file to handle form submissions, that I validate using the express-validator middleware. Now depending on the validation, I want to redirect the users to the same contact page but displaying either a success message when validation is successful (here I'll send an email), or display the error messages.
I didn't manage to pass the validation message to the template to display it. I tried almost all combinations of dynamic: true/false, res.locals = validationMessages, res.sessions = validationMessages, res.templateData = validationMessages with no success.
Furthermore, adding dynamic: true made the changes to the content not appear at all, whatever refresh strategy I use (private mode, cleaning cache, relaunching Docpad, refreshing without cache, etc.). I should probable file a bug about it.
How to ?
I'm using Docpad 6.53.0 (latest to date), node 0.10.15, on OS X 10.8.4
I cheated on this one a bit by appending a hash to the redirect url (eg: "www.mywebsite.com/#messagesent"). I then use client side javascript to read the hash and then show the appropriate message. Something like this:
if (location.hash == "#messagesent") {
$('#message-sent').show();
setTimeout(function () {
$('#message-sent').fadeOut(1000);
}, 1000);
}
Not quite what you were asking though :)