Using both .isDisplayed and .isEnabled? - selenium

Intro: I'm making automated tests with appium and I'm fairly new to it.
Newbie question: Is there any point making double assertions for elements using is.Displayed and .isEnabled?

Assertion .isEnabled means that the element is not disabled, to clarify this here is sample code:
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
Enabled: <input type="text" name="fname"><br>
Disabled: <input type="text" name="lname" disabled><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
First input is enabled and second is disabled, but both of them are displayed. But it could be also like this:
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
Not displayed and enabled: <input type="text" name="fname" style = "display: none"><br>
Displayed and enabled: <input type="text" name="fname" style = "display: inline-block"><br>
Not displayed and disabled: <input type="text" name="lname" disabled style = "display: none"><br>
Displayed and disabled: <input type="text" name="lname" disabled style = "display: inline-block"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Therefore there are different assertions for Selenium for different test cases. If you want a combination of both .isDisplayed and .isEnabled, use .elementToBeClickable. More information in documentation(JAVA)

Related

SiteFinity- Included Captcha Form Widget does not contain alt tag

SiteFinity noob here.
I've edited the widget via File Manager: Resource Packages>Bootstrap>MVC>Views>Captcha.
the file there is "Write.default.cshtml". I changed the following line-
<img data-sf-role="captcha-image" src='#Url.WidgetContent("assets/dist/img/dummy.jpg")'/>
to
<img data-sf-role="captcha-image" alt="captcha Image src='#Url.WidgetContent("assets/dist/img/dummy.jpg")'/>
However, although saved, this doesn't show up in the widget code when I put it on my form. I used File Manager, as I dont have a connection via .net editor.
Am I in the wrong place? Do I need to somehow restart the application?
Here is complete code:
#model Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.Captcha.CaptchaViewModel
#using Telerik.Sitefinity.Frontend.Mvc.Helpers;
#using Telerik.Sitefinity.Modules.Pages;
#using Telerik.Sitefinity.Services;
#Html.Script(ScriptRef.JQuery, "top", false)
<div data-sf-role="field-captcha-container" style="display:none;" class="#Model.CssClass form-group">
<div>
**<img data-sf-role="captcha-image" src='#Url.WidgetContent("assets/dist/img/dummy.jpg")'/>**
</div>
<a data-sf-role="captcha-refresh-button">#Html.Resource("NewCode")</a>
<div class="form-inline">
<div class="form-group">
<input data-sf-role="violation-messages" type="hidden" value='{"required": "#Model.ValidatorDefinition.RequiredViolationMessage"}' />
<label for='#Html.UniqueId("Textbox")'>#Html.Resource("TypeCodeAbove") </label>
<input id='#Html.UniqueId("Textbox")' type="text" data-sf-role="captcha-input" name="#Model.CaptchaAnswerFormKey" required="required" class="form-control input-sm"/>
</div>
</div>
<input type="hidden" data-sf-role="captcha-ca" name="#Model.CaptchaCorrectAnswerFormKey" />
<input type="hidden" data-sf-role="captcha-iv" name="#Model.CaptchaInitializationVectorFormKey" />
<input type="hidden" data-sf-role="captcha-k" name="#Model.CaptchaKeyFormKey" />
<input type="hidden" data-sf-role="captcha-settings" value="#Model.GenerateUrl"
</div>
#if (SystemManager.IsDesignMode)
{
var scriptUrl = Url.WidgetContent("Mvc/Scripts/Captcha/captcha.js");
var queryAddition = scriptUrl.Contains("?") ? "&" : "?";
var fullScriptUrl = scriptUrl + queryAddition + string.Format("_={0}", DateTime.UtcNow.Ticks.ToString());
<script type="text/javascript" src='#fullScriptUrl'></script>
}
else
{
#Html.Script(Url.WidgetContent("Mvc/Scripts/Captcha/captcha.js"), "bottom", false)
}
You'll need to make sure you are using the Bootstrap package. Go to Design > Page Template and see which resource package your page templates are using. Often times it's not the Bootstrap, but a copy of it.
A restart may help as well.

vue.js + Jest : how to test a form post?

Until now I gave been using Avoriaz, but I would like to use Jest now ...
found some tuts... but could not get any hint on testing my contact view component sending POST to an external urk...
<form id="contactForm" action="https://formspree.io/mysite.com" method="POST">
<div class="form-group">
<input type="hidden" name="_next" v-model="next" />
<input type="hidden" name="_language" v-model="language" />
<input type="hidden" name="_subject" value="Contact from my site" />
<input v-model="sendername" ...>
<input v-model="email" ...>
</div>
<div class="form-group">
<div class="uk-margin">
<textarea v-model="message" ...></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary btn-gradient submit">Send</button>
</form>
As the external post URL is only valid for production... I would like mock it and use the _next property as a callback page url...
any useful links to put me on first tracks ?? thanks a lot for feedback
You should prevent submit and post data using axios for example and then mock axios.
<!-- the submit event will no longer reload the page -->
<form v-on:submit.prevent="onSubmit"></form>
It's an easier way to unit-test that.

Unable to use vanilla JS for AWS Cognito, and get AmazonCognitoIdentity is not defined

I follow the instructions from https://github.com/aws/aws-amplify/tree/master/packages/amazon-cognito-identity-js
Here is my html code:
<html>
<head>
<title>Testing AWS Cognito</title>
<script src="/js/aws/aws-cognito-sdk.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.211.1.min.js"></script>
</head>
<body>
<div>
<input type="text" id="email" name="email" placeholder="email"> <br/>
<input type="text" id="username" name="username" placeholder="username"><br/>
<input type="text" id="phone" name="phone" placeholder="phone"><br/>
<input type="text" id="password" name="password" placeholder="password"><br/>
<button id="signup" onClick="register()" >Register</button>
</div>
<script>
const register = function() {
console.log("onclick loading now");
var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
}
</script>
</body>
</html>
But when I run it, it gives me:
"signup_aws_test.html:32 Uncaught ReferenceError:
AmazonCognitoIdentity is not defined"
I am very sure both files are loaded before I click the button.
in the aws-cognito-sdk.js, I can see that AmazonCognitoIdentity exists and exports. It doesn't seems like it is in the global namespace though.
Do i need to run something else to "Load" it?
Problem solved.
The file name MUST BE
"amazon-cognito-identity.min.js"
although the content the same, the filename matters.
Once I change it to amazon-cognito-identity.min.js, it works.

Remove content from input

can someone help me out with this script. I am trying to do a Formular for submit a recipe.
I want to do a dynamic ingredient formular, where i can add and remove ingredients.
Unfortunately it doesn´t work as I want. My removing function is always removing the first ingredient. How can I remove the the igredient I want to.
Here is my code so far:
function copy(objButton)
{
if(objButton.parentNode)
{
hinzufg=objButton.parentNode.cloneNode(true);
objButton.form.appendChild(hinzufg);
for(j=0;j<objButton.form.lastChild.childNodes.length;++j)
{
if(objButton.form.lastChild.childNodes[j].type=='text')
{
objButton.form.lastChild.childNodes[j].value='';
break;
}
}
}
}
function remove(objButton)
{
var entf = document.getElementById('ingredients');
entf.parentNode.removeChild(entf);
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Recipe</title>
</head>
<form action="">
<h2>Recipes</h2>
<strong>Name</strong> <br />
<input type="text" size="50" > <br /><br />
<strong>Ingredients</strong> <br />
<div id="ingredients">
<input type="text" id="AmountIngredients" name="zutatMenge1[]"> ...
<input type ="text" id="zutat" name="firstIngredient[]">
<input type="button" value="+" onclick="copy(this)">
<input type="button" value="X" onclick="remove(this)">
</div>
</form>
<body>
</body>
</html>

Yodlee FastLink "An error occurred while processing the request or session is invalid"

I am working on implementing a FastLink2.0 Integration for aggregation in my application. I saw from this post that the interface needs to be called from an HTML form and not just a simple REST GET request.
I was able to get a simple html page to work and redirect to FastLink, but when I put the page into an iframe (as the documentation recommends), it says "An error occurred while processing the request or session is invalid"
<iframe src="fastlink.html"></iframe>
fastlink.html:
<html>
<head>
</head>
<body>
<div class='center processText'>Processing...</div>
<div style="visibility: hidden">
<form action='https://node.developer.yodlee.com/authenticate/restserver/' method='post' id='rsessionPost'>
RSession : <input type='text' name='rsession' placeholder='rsession'
value='<--user token-->'
id='rsession'/><br/>
FinappId : <input type='text' name='app' placeholder='FinappId' value='10003600' id='finappId'/><br/>
Redirect : <input type='text' name='redirectReq' placeholder='true/false' value='true'/><br/>
Token : <input type='text' name='token' placeholder='token'
value='<--authenticated token-->' id='token'/><br/>
Extra Params : <input type='text' name='extraParams' placeholer='Extra Params' value=''
id='extraParams'/><br/></form>
</div>
<script>document.getElementById('rsessionPost').submit();</script>
</body>
</html>
Anyone figure this out? Thanks in advance!
Please follow the steps-
Here is the simple example of how to invoke fastlink in an iframe:
In post.html
<div class='center processText'>Processing...</div>
<div>
<form action='https://node.developer.yodlee.com/authenticate/restserver/' method='post' id='rsessionPost'> RSession :
<input type='text' name='rsession' placeholder='rsession' value='08062013_0:829d770b5c7d29e300a7dabc42108383ecac552de57a9706ed4077c98acde1e29e874e676651813a95543b8fb5e2d5face054f300a03b34e7105976867dde3' id='rsession'/>
<br/> FinappId :
<input type='text' name='app' placeholder='FinappId' value='10003600' id='finappId'/>
<br/> Redirect :
<input type='text' name='redirectReq' placeholder='true/false' value='true'/>
<br/> Token :
<input type='text' name='token' placeholder='token' value='7346ddfb28f1eef2acdc4943695680337a3e5ea2ae9bb88c35d0ed58c702b6' id='token'/>
<br/> Extra Params :
<input type='text' name='extraParams' placeholer='Extra Params' value='' id='extraParams'/>
<br/>
</form>
</div>
<script>document.getElementById('rsessionPost').submit();
</script>
Then invoking this in iframe:
In test.html:
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<iframe src="post.html"></iframe>
</body>
</html>
Hope this helps.
Regards,
Krithik