iMacros for Chrome: How to replay Macro if error occurred? - imacros

I have this simple 3 line macro to load a form and submit, sometime I get this "RuntimeError: element SPAN specified by TXT:Submit was not found, line: 3" how can I auto replay the macro? I would like to replay the macro until the form is submitted. I am using iMacros for Chrome Version 10.1.1, thank you.
SET !TIMEOUT_STEP 0
URL GOTO=https://docs.google.com/forms/......
TAG POS=2 TYPE=SPAN ATTR=TXT:Submit

Yeah, well..., your !TIMEOUT_STEP (=0) is "(part of) the problem"...!
'Google' Docs/Forms are "known" to be pretty "heavy" Pages that take "some time" to load, (especially if you are the Owner/Editor of the Doc/Form), and even when the Browser "thinks" that the Page has fully loaded (and tells iMacros (after the URl GOTO), => "Go on, the Page has loaded, you can proceed with the rest of the Script"...), there is probably still some background JS Validation on the Page/Fields (Required Fields, Data Formatting, etc...), before that 'Submit' Button will appear or get Activated...
Use a longer Setting/Value for !TIMEOUT_STEP, => at least =1, but =3 or the Default =6 would also be OK and much more "reliable" than your =0...
And/or, add a mini-WAIT Statement after the URL GOTO.
And/or, add a mini-!PLAYBACKDELAY Statement at the beginning of the Sccript, or at least after the URL GOTO.
... Other Techniques are also available to "increase Reliability" (=> loop the Script with !ERRORIGNORE activated and conditionally abort it (with EXTRACT + EVAL() + MacroError()) when successful, set any of the 'Timeout' Options I mention conditionally, combined with extracting the "Result" after clicking on the 'Submit' Button, etc...), but they will all be "fighting" against your !TIMEOUT_STEP=0 which is too short...

Related

distinguish whether page was reloaded or not in Django views or in template

Django question
I would like to ask whether it is possible or not to distinguish in view or in template if page was reloaded or page was reached by url from the other page? If shorten it out, need to know if it is any marker that would indicate that page got reloaded by F5 or whatever?
Perhaps it is probably possible to figure out by analyzing request.
Only 1 idea that comes to my mind is following:
request.get_full_path()# – specifies full address of the current page
request.META.get('HTTP_REFERER')# – specifies full address of previous page
So that theoretically if former == last – page is reloaded, but it doesn't work this way.
If you know any solution or hint -please communicate it.
Thank you and have a nice day!
you can do one thing:
use one hidden element in your template like this :
<input type="hidden" id="anyId" name="anyName" value="">
then call a fn to assign value to this element when page reloads
<body onbeforeunload="assignValue()>
<!--put your stuff-->
<script>
function assignValue(){
document.getElementById("anyId").value="reloaded";
}
</body>
because of onbeforeunload on page load assignValue() fn will be called.
then you can check this value of input element in your backend if value is not empty i.e. "" means page is loaded

Regex in capybara have_xpath

I have a text changing decoration when it is clicked. In my tests before clicking I want to check whether it's already clicked or not. It changes color, text decoration and href which I want to check through.
As href contains session specific information, so I want to use regex.
if page.have_xpath("//a[contains(#href,\"%20Administrators?\")]")
This passes even the page has already been updated and Administrators text has changed to something else.
How should I correct the syntax to accept all href containing "%20Administrators?" text. I want add it to if clause as if the page has the link with text Administrators in it.
Before clicking: href="/sometext/%20Administrators?redirect=sometext"
After clicking : href="/sometext/%20Standard?redirect=sometext"
The primary issue you're having here is using have_xpath rather than has_xpath?. have_xpath returns an RSpec matcher, and as such when used with if will always evaluate as true (since it returns an object and hasn't yet actually evaluated any XPath passed in). has_xpath? returns a boolean result of true or false.
if page.has_xpath?('.//a[contains(#href,"%20Administrators?")]')
The second issue is that your question asks about regex, but XPath 1.0 (which browsers support) doesn't have regex support and your XPath isn't using regex at all (just a contains expression). If you actually want to use regex for testing the href (and have better reading code) you should be using the has_link? boolean method - along the lines of
if page.has_link?(href: /Administrators/)
has_link? can also verify the visible text of the link too if wanted
if page.has_link?('Visible text of the link', href: /Administrators/)
Finally, when using XPath with Capybara, 99% of the time you should start your XPath with .// instead of just // - see https://github.com/teamcapybara/capybara#beware-the-xpath--trap - and is one reason why it's usually cleaner to use CSS and/or the more specific methods provided by Capybara rather than the xxx_xpath methods.
One other thing to note is that all of the methods mentioned have waiting behavior by default, so they will wait up to Capybara.default_max_wait_time seconds for the page to have a matching link. If you know the page is stable and just want to immediately know whether or not a matching link exists you might want to pass wait: false as an option
if page.has_link?(href: /Administrators/, wait: false)

Auto-filling Word documents with Access VBA: Normal.dotm template issues

A somewhat similar question has been asked before, but the solution didn't work for me.
For instance, http://www.xtremevbtalk.com/showthread.php?t=99503
Background:
I have a MS Access 2010 database. In my database I have a form with a button. I've programmed the button to open a saved word document, populated book-marked places in the document, then save-as the word document with a name that includes the time (henceforth referred to as the auto-filled document). This all works just fine.
The problem:
If a different MS word document was already open when I clicked the button, then I have trouble closing the resulting auto-filled document. This is what happens:
1) I try to "x" out of my auto-filled word document.
2) the computer tells me that "This file is in use by another application or user // (C:....\Normal.dotm)"
3) I click "ok"
4) it offers to save-as the Normal template.
5) I click "cancel"
6) I try to "x" out of the word application once more.
7) the computer prompts me: "Changes have been made that affect the global template, Normal. Do you want to save those changes?"
8) I click "Don't save"
9) the application closes.
(This only occurs for instances when a word document is already open when I click the button on the form. Otherwise it works perfectly.)
My question:
Normally, I would just shrug and live with these extra few steps, but I'm the one making the database, so I have to think about my users. (Would it mess anything up to save the normal template--step 7?)
I googled this for a while. For similar situations, some people suggested adding objApp.NormalTemplate.Saved = True (where objApp is the Word application object), but this did not work for me.
Can someone please tell me what's going on? Is there a solution?
Any help will be much appreciated.
What you need to do is check to see if an instance of Word is already open. If it is, you might want to let your user know they need to close their Word doc.
' Handle Error In-Line
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
If Err.Number = 429 Then
'If we got an error, that means there was no Word Instance
Set objWord = CreateObject("Word.Application")
Else
Msgbox ("You're going to need to close any open Word docs before you can perform this function.", vbOK)
Exit Sub
End If
'Reset Error Handler
On Error GoTo 0

CFBuilder 2 insert closing tag does not work

I am using CFBuilder 2 (free version) and the insert closing tag functionality does not seem to work.
Here are my settings:-
Now if I type in a new openning tag e.g. <cfscript> I never get the closing tag. Am I misunderstanding what it is supposed to do or is there some other setting I should be changing?
This worked well in cfeclipse and so is incredibly frustrating.
Thanks.
Check the "typing" preferences page. There is a setting called: "auto-close tags". You probably have this set to "never". Try setting it to "When typing '>' of start tag". See attached image:

C++, web browser control: cannot change encoding/charset

There's a document I'm displaying in a web browser ActiveX control hosted in a C++ app. This document has a META tag that specifies incorrect charset, so the output is funny. I know the correct encoding and want to change it programmatically to fix that. But whatever I try, the encoding remains unchanged.
I alredy tried, in various combinations and flavors:
IHTMLDocument2::put_Charset (after the document finished loading);
changing the "charset" property of the "META" tag (using IHTMLMetaElement);
deleting the "META" tag altogether (by setting its "outerHTML" to empty string);
refreshing the control.
The control demonstrates remarkable persistence in preserving the incorrect encoding. What are my other options? I can't manipulate the source of the document being loaded.
try to put the designMode property "On".
According to this, it should work if you call IWebBrowser->Refresh() after calling IHTMLDocument2->put_charset().
Here's what eventually worked:
In the handler of the "NavigateComplete2" browser event,
the charset is modified using the charset property,
then the META tag is thrown away by setting its outerHTML to empty string,
and then the control is refreshed.
Modifying the order of these actions, or omitting a step, will render the entire operation void. MSHTML is picky.