Submit a web form just refreshes the page - excel

I'm trying to submit a form but every time I hit the submit button instead of submitting the data it just straight refreshes the page.
I was originally able to get it to work by doing:
doc.getElementByTagName("button")(1).Click
but it stopped working a couple of weeks ago which makes me think something on the website changed.
I've since tried using a queryselector & also just submitting the form using form.submit but get the same result of not submitting any data & just refreshing the page.
The line of code that submits is:
<button data-testid="submit-eligibility" class="rds-primary-button is-white-labeled-btn eligibility-lookup__PartnerButton-sc-13jrfc8-1 dDEqAx">Submit</button>
I also can't use selenium because it is on a work computer & I am unable to download or install anything without admin privileges.
Any help would be greatly appreciated.
Thanks!
This is the website that I've been trying to submit the form:
https://www.partneroptumfitness.com/
I use sendkeys to input the values from excel & that code still works but I can't even get an error saying that this field needs to be filled out before submitting which is what it normally does but doesn't even show that any longer.
I'm trying to submit the second form on the page.

Related

How to follow a link that is actually a click button

I need to fill a form aproximately 100 times a day. I tried with selenium but it is quite slow because it is using a web browser. It's working quite well with mechanicalsoup until I need to click "Accept" button. Clicking it activates other tables that need to be filled but are inactive before clicking this button. I tried to point to the button and then br.follow_link(button) unsuccesfully. I attach the piece of HTML that I need to fake. I'm looking for a way to produce the effect of clicking avoiding using Selenium.
Aceptar
Sounds like you need JavaScript capability so the button's click would render the tables, but MechanicalSoup doesn't do Javascript.
MechanicalSoup's docs says:
MechanicalSoup automatically stores and sends cookies, follows redirects, and can follow links and submit forms. It doesn’t do Javascript.

Why does selecting the browser Refresh button not replace edited fields in my JSF form with values from server? [duplicate]

This question already has answers here:
javax.faces.application.ViewExpiredException: View could not be restored
(11 answers)
Closed 4 years ago.
During normal operation, everything works well on my Java EE note taking application running on GlassFish 4.1.2 with STATE_SAVING_METHOD set to server. I can open the ViewScoped Note.xhtml client in my Firefox browser; type text in the CKEditor field; select the [Create] button to save the note to the Derby database; edit the text and finally select the [Update] button to update the note information in the database.
The only issue that I have is when I edit my note and don't select create or update before the view expires. When this happens, the server reports a ViewExpiredException, and I see my default PrimeFaces error page.
Luckily, I discovered that I can perform the following steps to save the edited data.
Select the browser back button.
Select the browser refresh button.
Select create or update buttons on the client.
When I select the browser back button, I see the previously edited page. I believe this is because the browser cached the page locally and is displaying the cached version of the previous page. The browser does not appear to communicate with the server when I select the back button.
If I select the create or update button immediately after selecting the back button, I see the ViewExpiredException again.
However, if I select the back button and then the refresh button, I can save or update my edited note.
I believe that selecting the refresh button creates a new view for the page but what I don't understand is why I don't lose my edits. When I select the refresh button, the server reports it creates a new backing bean and goes to the server to get the data for note. I would have expected the server to send this information back to the client and overwrite the edited values but it doesn't. After the refresh, a new view is created (I think?) but the client still has the edited values. When I select the update button the edited values are saved in the database.
I'm very glad that it works this way, because, if it didn't, I would lose my edits every time the view expired.
My question is why does it work this way. What I am missing about the JSF lifecyle that allows the browser to create a new view using a form containing edited data?
I read javax.faces.application.ViewExpiredException: View could not be restored before posting this question. This question builds on that question by specifically looking at what happened to edited data in a form when the page is refreshed when the view is expired which was not addressed in the original question.
To get rid of the set values when the user refreshes the page, set textbox/textarea autocomplete to off or create a function that will check whether the variables are null or not during the prerenderview event or in the constructor. If they aren't null, make them null.

Click <span>? element or button without name or get submit to work

I've been poking around the internet at large cobbling together some VBA code to try to interact with some web pages (and eventually scrape).
I have some decent knowledge of VB and programming, but the internet end of things is pretty new to me, especially the syntax of commands, so I'm leveraging things from the internet.
I have one that's working,
http://snowload.atcouncil.org/
This I can fill in and get to submit with a
doc.getelementsbyId("coordinate_address").value = range("City").value _
& ", " & range("State").value
doc.getelementsbyId("btn-submit").click
then wait it out until readystate =4 , etc.
The one I can't get to work is here.
http://windspeed.atcouncil.org/
This one seems to use a object that I can't figure out how to click. It doesn't seem to have a name, and Id, etc.
If I use conventional 'submit' on the windspeed page, (loosely using that term), the page loads, but it comes out blank. Like I'm not using the syntax correctly, or not passing a variable/searchform somehow.
ie.document.all.item("submit").click
This 'works' but it produces a blank page with the east coast of africa and no data.
In the immediate/console of the browser, after I click, say, the Hawaii button, it works with document.searchform.submit()
If I try that in code, it doesn't work. (The Immediate window in the VBA editor thows me a "expected: =" error,
The object I am trying to click is in the web site code.....
<span>
<input type="submit" value="Get Windspeed" onclick="valbutton(searchform); return false;">
<span>
I've tried a lot of techniques poached from the internet, but no success yet. (looping over elements using getelementsbyclassname "span", but it either doesn't find the one with value ="Get Windspeed", or it doesn't find it at all.
somehow triggering the valbutton (that's a subroutine/function on the page) seems like a workaround... but VBA seems to want different syntax than the console on the web page and it's doing the same kind of "expected: =" syntax error when I try that approach.
I suspect normal submit would work, but I'm somehow not passing the filled out page and am sending a blank to the submit/get?
I also notice that if you are on the page, type in an address, and hit enter, it runs that "find" button I can't figure out (same thing, no name or ID obvious, it's a button....), and if you hit enter after it reloads, then it somehow by default hits that 'get windspeed' button, which suggests to me they are both submit buttons in a way.
Thanks for reading, I appreciate any thoughts on the matter. I am trying to get this to get all the data input and get the results without adding anything beyond VBA (i.e. jscript or vbscript or other things,)
-Brian
You should be able to simply submit the form after setting the .Value of the inputs.
doc.getelementsbyId("searchform").submit
I was able to adapt this (despite the claim this doesn't work in IE11..., maybe I'm not using 11...Is eleven Miscrosoft Edge?)
https://www.mrexcel.com/forum/excel-questions/344297-need-visual-basic-applications-code-execute-javascript.html
IE.Document.parentWindow.execScript "CheckAndSubmit(document.frmViewMyAcct);"
that allowed me to mimic hitting the button or hitting submit and somehow got around the 'no information / resulting page is blank' issue. The onclick event has a javascript routine attached to it, so I just copied that syntax.
Thanks for the help, it got me started on the solution.
Regards,
Brian

NODE.JS: Submit form without page reload?

I have a form with action attribute and within: input text and submit. When the user presses submit, the information they provided will be used to send a text message using Twilio. My question is how do I do this without reloading the page or going to another a page? Instead, I would rather have a cool small animation that displays whether it sent successfully or not, with the page remaining the same.
Thank you for your help. Much appreciated!
I basically did what zeronone said with listener on submit event, but instead wrote "return false;" preventing the page reload. I then included ajax, and the rest of the code remained basically the same.

Seam:token tag not being respected

When I click a command button, and then hit the browser back button to the form and click it again, it submits a second time without throwing the proper exception...
Even stranger, the form id itself is DIFFERENT when I come back, which implies it has regenerated a "valid" form id at some point.
Here's the relevant code: Any ideas?
<h:form id="accountActivationForm">
<s:token/>
<a4j:commandButton id="cancelActivateAccountButton"
action="#{controller[cancelAction]}"
image="/images/button-Cancel-gray.gif"
reRender="#{reRenderList}"
oncomplete="#{onCancelComplete}" />
 
<a4j:commandButton id="activateAccountButton"
action="#{controller[agreeAction]}"
image="/images/button-i-agree-continue.gif"
styleClass="activate-account-button"
reRender="#{reRenderList}"
oncomplete="#{onActivationComplete}"/>
</h:form>
Clarifications:
I inherited this, so I'm trying to change it as little as possible. (It's used in a couple places.)
Each action returns a view, not null. I have confirmed this by stepping through line-by-line.
The reRenderList is empty in my current test-case.
onActivationComplete is also empty.
I'm going to be going template-by-template to see if someone made it with nested forms, because my coworkers have had unrelated problems due to that, so it couldn't hurt to eliminate that as a possible problem.
The s:token is supposed to avoid double/multiple submits by impatiently clicking the submit button multiple times in the same request or by refreshing the non-redirected result in the webbrowser or by resubmitting the cached page in the browser history.
That it works when the client navigates back and forth by browser history just means that the pages with the forms are not cached in client's browser history and are requested as brand new from the server side again. That would indeed return a new token. Check it yourself with a HTTP tracker like the one in Firebug.

Resources