Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could this be done with a macro, or require programming?
#1
I'm sorry to ask such a naive question, but I'm new to this product.

1) I have a flat text file with distinct field markers (pipe delimited fields with newline records)

2) I need to feed the flat text file fields into a web-based application (nothing weird, just alpha-numeric text into browser fields -- a web-based form)

It's really just a plug and chug -- I don't need any logic at all.

So I have three questions:

1) Does the existing macro language allow for basic text file access and line-item parsing (i.e. searching for delimiters)? Or do I need to go straight to the programming API (i.e. the C# routines)?

2) Do web-based applications pose any additional challenges? How does the application know if the web page has refreshed and/or accepted the data? Does the QM script depend on the browser?

... and the most important question:

3) Is there anyone here who would be willing to look at my project in greater detail and do 4/8 hours of consulting and programming? If this first application works, there are several (6+) client applications that I would need to force-feed this flat file into.

Thank you in advance,

Brian
#2
1) and 2)
Macro parse text file (table) and populate web form
Code:
Copy      Help
out
;create a file with a text table for testing
str testFile="$temp$\test.txt"
str testTable=
;a | b|c
;d|e| f
testTable.setfile(testFile)

;variables
ARRAY(str) a; int i
int isCSV=0 ;;change to 1 if the text table is in CSV format

;this code shows 2 ways of converting a text table into a 2-dim array
if isCSV
,ICsv csv._create
,csv.Separator="|"
,csv.FromFile(testFile)
,csv.ToArray(a)
else
,str s fileData.getfile(testFile)
,a.create(3 numlines(fileData))
,foreach s fileData ;;for each line
,,tok s &a[0 i] 3 "|" 0x2000 ;;split into 3 parts, using | as separator
,,i+1

;this code shows what we can do with the array.
;We'll use Firefox and the Google advanced search page as a test form: http://www.google.ca/advanced_search
int w=win("Google Advanced Search - Mozilla Firefox" "MozillaWindowClass")
act w ;;activate window
for i 0 a.len ;;for each line
,;fields of this line are in array elements a[0 i], a[1 i] and a[2 i]
,out F"{a[0 i]},{a[1 i]},{a[2 i]}" ;;show in QM
,
,;we can use accessible object functions to focus web page objects. Let's focus the first text input field.
,Acc a1.FindFF(w "INPUT" "" "name=as_q" 0x1004 3)
,a1.Select(1)
,
,;To pass a[0 i] etc to the web page, you'll probably use key, and finally click a Submit button.
,;In IE also could use use accessible object functions or HTML element functions. Not in Firefox and Chrome.
,key (a[0 i]) T (a[1 i]) T (a[2 i]) ;;enter each value and press Tab to focus next field
,key Y ;;press Enter to submit
,
,;now how to know when the submit is finished?
,;There are several ways.
,;1. If web browser window name changes, wait for the new name.
,wait 30 WT w "* - Google Search - Mozilla Firefox" 1
,;2. If Internet Explorer, can wait until web page is loaded. To create code, use this dialog: "Wait", action "Wait for web page". Similar functions for Firefox and Chrome exist somewhere in the forum, but they are less reliable.
,;3. Wait for an object that exists only when the web page is finished loading or updating. To create code, use this dialog: "Find accessible object". It works with Firefox, Chrome and IE. With IE also could use "Find HTML element".
,Acc a2.FindFF(w "" "Web" "" 0x1001 30) ;;note the 30, it makes the function to wait for the element max 30 s
,;4. If Internet Explorer, instead of Enter we could find the Submit button as an HTML element and call its Click function. In most cases it is synchronous and probably would wait until everything is refreshed etc. With Firefox and Chrome we can use only accessible object functions; the similar accessible object function DoDefaultAction is not synchronous.
,;5. If none of the above works, try to wait for a captured image. Use dialog "Find image".
,;6. Give up and simply wait eg 10 s.
,
,key B ;;press Backspace to return to the form, to test next line

;The best web browser for web page automation is Internet Explorer.
3) not me. But you can ask "how to do this" questions here, I'll try to answer, or somebody else.


Forum Jump:


Users browsing this thread: 1 Guest(s)