How to write xpath for span element which generate messages dynamically? - xpath

In the app I used, resolutions will be there to which a user can commit.
I committed to a resolution, which gives a message:
You have committed successfully to this resolution'. Here is the html code for that message.
HTML for that messages is:
<div id="sliding_info_container" class="hidden" style="display: none;">
<span id="sliding_info" class="success">You have committed successfully to this resolution</span>
Now if I uncommit that resolution, app gives another message:
Resolution uncommitted successfully
Here is the HTML code for that message:
<div id="sliding_info_container" class="hidden" style="display: block;">
<span id="sliding_info" class="success">Resolution uncommitted successfully</span>
My script for first action contains xpath=//div/span[#class="success"], value=You have committed successfuly to this resolution.
When I run this command selenium gives an error: Actual value 'Resolution uncommitted successfully' did not match 'You have committed successfully to this resolution'
What I have given in the script is the right value, and that is the message app is displaying. Why selenium is giving out error for a valid command?

Try below code:
//span[text()='You have committed successfully to this resolution']

try this:
//div/span[#class="success"]/text()

Related

Why is JMeter showing an undefined variable error in the response body even if the web page is working properly if I run it manually?

(1/1)
ErrorException
Undefined index: current_institute_id
I am getting above error in jmeter response body but its working fine if i run web page manually . Also i have passed the value of current institute in request.
enter image description here
enter image description here
<div class="container">
<div class="trace trace-as-html">
<table class="trace-details">
<thead class="trace-head"><tr><th>
<h3 class="trace-class">
<span class="text-muted">(1/1)</span>
<span class="exception_title"><abbr title="ErrorException">ErrorException</abbr></span>
</h3>
<p class="break-long-words trace-message">Undefined index: current_institute_id</p>
</th></tr></thead>
<tbody><tr><td><span class="block trace-file-path">in <span title="/var/www/html/mycc/t11/app/Http/Controllers/inquiry/AdmissionFormController.php line 1666"><strong>AdmissionFormController.
As I can see in the Screenshot the information provided is not enough to completely investigate the issue. But I can notice that the data you are sending is not recognized by the server. This means you may be sending data that the server was not expecting.
The solution is to record the script manually after understanding the flow.
Found a video explaining the process. Maybe it'll help you understand the way how you can record manually and not depend on tools that ultimately misguide you.
https://www.youtube.com/watch?time_continue=10&v=Njjz1kzS24E
I'm not sure that'll help with the information provided by you. But it may lead you to a solution

parsley.js 'fails' when trying to validate checkbox

We are re-designing a site and part of that re-design involves making the site accessible to screen readers and the like. I'm using latest version (2.8.0). Here's what's happening --- validation for all text, select and textarea fields in our forms work perfectly. In order to be accessible, checkbox and radio inputs are wrapped in tags. The html for a set of checkboxes looks like this:
<div class="form-group">
<p id="applicant_type_desc" style="margin-bottom: 6px;"><strong>I am: <span class="text-danger" aria-hidden="true">*</span><span class="sr-only">Required</span></strong> <em class="small">(check all that apply)</em></p>
<div class="checkbox">
<label id="applicant_type_patient_desc">
<input type="hidden" name="applicant_type_patient" id="" value="N">
<input type="checkbox" name="applicant_type_patient" id="applicant_type_patient" value="Y" {checked_applicant_type_patient} aria-labelledby="applicant_type_desc applicant_type_patient_desc" data-parsley-multiple="type" data-parsley-error-message="Please specify whether you are a patient, relative, employee or other.">
A patient
</label>
</div>
followed by more checkbox divs without error messages and ended with an end div for the for form-group wrapper.
If I load the form and click 'submit', all the text fields are validated properly. If I add 'required' to the checkbox above, when 'submit' is clicked nothing happens and the form is submitted with no validation at all.
The same thing happens when I try to validate a radio button set as required.
There is some custom jQuery and parsley code which creates a div to hold all the error messages and transforms the error messages into links to the field id so that a screen reader can follow them and focus on the field in error. But imho, this should have no effect on why the form validation doesn't kick in.
I'm absolutely baffled.
FYI - I tried this using an earlier version (2.0.3) of parsley and the validation actually worked, although all my custom error processing was ignored.
Any insight would be greatly appreciated.
As it turns out, parsley handles the errorswrapper element differently for text, textarea and selects then it does for checkboxes and radio buttons.
The starting wrapper element for text, textarea and select contains the parsley-data-id attribute whereas checkbox and radio button elements contain the parsley-data-multiple attribute whether that was generated by parsley or entered manually in the html.
My code was looking for parsley-data-id and, of course the jquery selector failed and generated an error. A colleague was able to spot this for me while we were looking at the page in chrome inspector. Once i saw the error, making a simple adjustment to the form:error event function allowed everything to work.

How to make Error Message Readable by JAWS

I have following Error message on screen, but its not readable by JAWS version 15 screen reader.
<span aria-live="assertive" aria-invalid="true">
<span class="accessibleText">Error</span>Enter a valid Phone number.</span>
I have also tried role='alert' and aria-atomic='true'properties but its still not readable on Chrome and IE browser.
You need a role="alert" and you need a change to the DOM (text) inside the role="alert" element. Use JavaScript to change the text inside the accessibleText span, or add/remove the entire span from the DOM with JavaScript.
More details here: Jaws doesn't read error message
<span aria-live="assertive" aria-invalid="true">
<span role="alert" class="accessibleText">Error</span>Enter a valid Phone number.</span>

<Spring MVC> Second form on same page causing a lot of errors

A short while ago it was decided that our 'support' tool needed some reforming. This included design and technically. One of these things was making several selections, which were present on any form in the tool, session-scoped.
For this purpose it was decided that we extend our menu-bar with a second form. The form right now is causing a lot of trouble. Namely:
Some pages don't load at all, and instead give a net::ERR_INCOMPLETE_CHUNKED_ENCODING error.
If a page works and I submit the form, the following error occurs: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
Whenever I debug the controller-class, it steps through the code and recognises the bound fields, and assigns them to the linked command-class. Whenever I submit the original form (Not the one from the menu-bar) no errors occur.
This is my form (As it stands now, with testing and all that):
<form:form method="post" action="userbar">
<form:errors path="*" cssClass="error"/>
<span id="headerImageLeft"><img src="<c:url value="/static/images/temp_tc_logo.png"/>" alt="Ticketcounter"/></span>
<li id="menuItemProfile"><spring:message code="button.profile" /></li>
<li id="menuItemChangeList"><spring:message code="button.change-list" /></li></a>
<li id="menuItemLogOff"><spring:message code="button.logout" /></li></a>
<li id="menuItemUsername">
<spring:message code="label.user"/>:
<c:out value="${user.username}"/>
</li>
<c:if test="${not empty clientsList || not empty casesList}">
<li id="menuItemClientBrowser">
Show Archive <form:checkbox path="showArchive" id="showArchive" value="showArchive" onchange="submit();"/>
</li>
</c:if>
</form:form>
The net::ERR_INCOMPLETE_CHUNKED_ENCODING is caused by the part. Whenever I remove that, every page loads normally. Even trying:
<spring:bind path="showArchive">
<input type="checkbox".../>
</spring:bind>
gives the error. Whereas on other .jsp files these tags work a-OK.
The pages are built using a template that picks the menubar.jsp and corresponding page-.jsp files and stitches them together. This way the menu is exactly the same throughout the tool.
I hope someone can help me with this issue, and if I've been vague about some things, or maybe if you possibly want to know more, please ask and I shall answer.
Managed to fix it. The errors seemed to have been an issue regarding the ModelAndView my Controller was returning in the onSubmit() function.
I changed it so that, instead of returning a ModelAndView with a URL ánd a Model, it simply returns a RedirectView. No more errors, except for when I change HTML form-elements to Spring form-elements.

Page update after asyncfileupload completes upload

I see this question asked frequently and I have done extensive experimentation to try to get this to work. However everyone else's examples and answers have so far failed me. I am bemused. Here is the situation:
AsyncFileUpload is NOT in an UpdatePanel
Image and Label to be updated are in an UpdatePanel
Update should occur after the upload completes
The upload is indeed saving the file as expected. My problem is regarding getting the page to update after that happens. The file being uploaded is an image, and I would like that image to update. I am aware of some problems with images not updating on the client if you reuse filenames, but I am also printing it to a label just to be sure. I am certain the UpdatePanel I am targeting is not updating.
I have tried the following approaches:
Using the server side method to manually update a conditional UpdatePanel - this fails because the file upload is done in a frame. Sniffing the returned HTML shows that the correct HTML is actually sent back after the post, but of course to the wrong frame.
Using the client side method to trigger a javascript postback to my UpdatePanel. This does not work and I cannot tell why.
Using the client side method to trigger a javascript button click inside the UpdatePanel. Again, nothing happens and I don't know why.
Setting the UpdatePanel's trigger up so that it points directly at the AsyncFileUpload. No joy, but I knew that would be a long shot, keeping in mind the hidden frame.
Moving the AsyncFileUpload into the UpdatePanel and trying some variety of the above. When I do this, I lose all handle of the file being posted to the server and I cannot save the file in the first place.
Normally when I get this kind of error, where all the tutorials appear to be wrong, it turns out that my error is because I didn't set an ID on a control somewhere and it somehow mattered. I can't even see that in this case. Here is some code.
<fieldset class="pj_Pics">
<ul>
<li>
<label>Picture 1</label>
<asp:UpdatePanel ID="ajax_Pic1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Image ID="img_Pic1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<div style="position:relative;">
<div class="photoChooser">
<ajaxToolkit:AsyncFileUpload ID="fu_Pic1" runat="server" CssClass="pj_PicChoose" Width="84px" OnClientUploadComplete="picPost1" OnUploadedComplete="fu_PictureFile_UploadedComplete" ThrobberID="throb1" />
<span><asp:Literal runat="server" Text="click to change"></asp:Literal></span>
<asp:Image ID="throb1" runat="server" ImageUrl="~/images/throbber.gif" AlternateText="uploading image" />
</div>
</div>
</li>
</ul>
</fieldset>
protected void fu_PictureFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
bla bla bla;
// and update the image
img.ImageUrl = "~/" + webfolder + imageFileName;
thing.Text = img.ImageUrl;
}
function picPost1(sender, args) {
document.getElementById('<%# Button1.ClientID %>').click();
}
Any help greatly appreciated. There is obviously a ScriptManager on the page and the code I've shown is just the last thing I have attempted. Let me know if there is anything else you need to see.
Thank you!
I happen to face the same situation today, and this is how I solved it.
According to this LINK, there's no Postback is happening or even a ViewState since its Asynchronous FileUpload.
So in OnUploadedComplete I test file type and size before executing the SaveAs() in codebehind, then I test the same in OnClientUploadComplete to display messages and carry on the rest of the work like setting Images URL. Hope this helps.

Resources