Web Testing


SUBMITTED BY: rilp44

DATE: Dec. 5, 2015, 1:55 a.m.

FORMAT: Text only

SIZE: 37.3 kB

HITS: 2151

  1. ''"iMacros has been an excellent addition to our development toolbox."''
  2. Ian Dominioni, United Parcel Service (UPS)
  3. For a quick high-level overview see also the [http://imacros.net/overview/web-testing iMacros Web Testing] product page.
  4. ==Performance Testing [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]==
  5. (Related example macro: Demo-Stopwatch)
  6. (Related example script: get-response-times.vbs)
  7. iMacros includes full support for in-depth performance testing (response time measurements).
  8. There are two approaches: Looking at the performance log (also called performace profiler) of the macro or inserting STOPWATCH commands at specific points in your macro. The performance profile is best if you do not know (yet) where to expect bottlenecks or issues. The STOPWATCH command has the advantage of creating less data and is best suited for monitoring known performance issues (e. g. the submit button in a shopping cart, when a 3rd party API is called).
  9. === Performance Profiling ===
  10. This feature is new since iMacros V7.35. Please see [[Performance_Profiler|Performance Profiler]] for details.
  11. === STOPWATCH ===
  12. The STOPWATCH command in iMacros allows you to measure the time that elapses between the first occurrence of the command in a macro ( = stopwatch on) and the second occurrence ( = stopwatch off). By using different identifiers in the STOPWATCH command you can create up to 100 independent measurement points in your macro.
  13. In order to do web site response measurements you need to insert the STOPWATCH statements manually after you recorded your macro. For accurate measurements it is important to set the browsers replay speed to FAST so no artificial delays are added.
  14. '''Demo Movie: [http://forum.imacros.net/_uploads/Stopwatch.htm Performance Web Testing with STOPWATCH]'''
  15. iMacros response time measurements always reflects the true user experience as they are measured using a real browser. Therefore response times measured by iMacros include loading times for browser plug-ins such as the Macromedia Flash Player or the Java runtime.
  16. By default the measured times are saved to the Downloads\ directory of your iMacros installation (e.g. C:\Program Files\iMacros\Downloads\). The default file name is macroName_stopwatch.csv. You can instruct iMacros to save the data to a custom file name by setting the built-in variable !FILESTOPWATCH.
  17. The values are comma separated (CSV format) so they can be viewed with any text editor, imported directly in Microsoft Excel or viewed by any other software you use. Additional information about the date and time of the measurements and the calling macro will be added to the response times.
  18. In this example we measure response times of different parts of the iMacros homepage:
  19. <nowiki>
  20. VERSION BUILD=8920312 RECORDER=FX
  21. TAB T=1
  22. 'Change the default stopwatch file name:
  23. 'The file is saved to iMacros DOWNLOAD folder
  24. '
  25. 'SET !FILESTOPWATCH C:\Temp\demo-stopwatch.csv
  26. 'Note: Use SET !FILESTOPWATCH NO if you do NOT need a response time log file
  27. '(for example, if you return the values to the Scripting Interface via iimGetStopwatch)
  28. '
  29. 'Start reponse time measurement
  30. 'Measure total macro runtime
  31. STOPWATCH ID=Total
  32. 'Measure load time for first page
  33. STOPWATCH ID=Firstpage
  34. URL GOTO=http://demo.imacros.net/Automate/StopWatchDemo
  35. STOPWATCH ID=Firstpage
  36. '
  37. TAG POS=1 TYPE=A ATTR=HREF:http://demo.imacros.net/Automate/AutoDataEntry
  38. TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:fname CONTENT=Tom
  39. TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:lname CONTENT=Tester
  40. 'Measure server reaction on submit
  41. STOPWATCH ID=SubmitData
  42. TAG POS=1 TYPE=BUTTON:SUBMIT FORM=ID:demo ATTR=TXT:Submit
  43. STOPWATCH ID=SubmitData
  44. STOPWATCH ID=Store1
  45. 'Measure time for secure Online store to open
  46. 'go to store
  47. URL GOTO=http://imacros.net/
  48. TAG POS=1 TYPE=A ATTR=TXT:*Buy*
  49. 'open store => start timer
  50. TAG POS=1 TYPE=A ATTR=TXT:Buy<SP>Now
  51. TAB T=2
  52. STOPWATCH ID=Store1
  53. 'Measure time for second page
  54. STOPWATCH ID=Total
  55. '
  56. WAIT SECONDS=2
  57. URL GOTO=http://demo.imacros.net/Automate/StopWatchReport
  58. TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form1 ATTR=ID:path CONTENT="In iMacros Downloads folder"
  59. </nowiki>
  60. This macro will create the following data in the "performance_Stopwatch.csv" file - obviously the response times will be different when you replay this macro. The format of the file is:
  61. YYYY/MM/DD, HH:MM:SS, Macro name, ID, time (s)
  62. "5/13/2015","14:04:42","FIRSTPAGE","0.893"
  63. "5/13/2015","14:04:44","SUBMITDATA","0.747"
  64. "5/13/2015","14:04:51","STORE1","7.102"
  65. "5/13/2015","14:04:51","TOTAL","9.477"
  66. For more information please see the [[#Tips_for_Accurate_Web_Response_Time_Measurements|Tips for Accurate Web Response Time Measurements]].
  67. ===Automating Response Time Measurements ===
  68. (Related example script: get-response-times.vbs )
  69. If you want to automate reponse time measurements it is likely that you will call iMacros from another application. Instead of writing the response time to a log file the data can be sent to your application via the Scripting Interface. Simply use the extract feature. The last recorded response time value is stored in the built-in !STOPWATCHTIME variable. You can use this variable as follows to transfer the response time data to the calling script or program:
  70. VERSION BUILD=7500718 RECORDER=FX
  71. TAB CLOSEALLOTHERS
  72. TAB T=1
  73. 'Change the default stopwatch file name:
  74. 'The file is saved to iMacros DOWNLOAD folder
  75. '
  76. 'SET !FILESTOPWATCH C:\Temp\demo-stopwatch.csv
  77. 'Note: Use SET !FILESTOPWATCH NO if you do NOT need a response time log file
  78. '(for example, if you return the values to the Scripting Interface via iimGetStopwatch)
  79. '
  80. 'Start reponse time measurement
  81. 'Measure total macro runtime
  82. STOPWATCH ID=Total
  83. 'Measure load time for first page
  84. STOPWATCH ID=Firstpage
  85. URL GOTO=http://demo.imacros.net/Automate/StopWatchDemo
  86. SET !EXTRACTADD <nowiki>{{!STOPWATCHTIME}}</nowiki>
  87. STOPWATCH ID=Firstpage
  88. Thus, the data is added to the !EXTRACT variable. Its contents can be obtained via the "iimGetLastExtract" command.
  89. Note: "SET !FILESTOPWATCH NO" instructs iMacros not to create a response time log file. This is useful if you intend to return the values via the Scripting Interface.
  90. ===Tips for Accurate Web Response Time Measurements ===
  91. [[Image:Reponse-time-data70a-256.png|thumb|150px|Sample measurements with a modified Demo-Stopwatch macro running on the iOpus.com Dallas monitoring server]]
  92. * Add a CLEAR statement to your macro. This way you can make sure that the browser cache is cleared before each run. Otherwise iMacros might read the web pages from the cache and not the web server, which would most likely result in lower response times. Whether the cache is actually used depends on the Internet Explorer settings.
  93. * Run the measurements as a loop and average several runs. The "internet speed" can fluctuate from minute to minute even on a fast connection. Therefore differences between each measurement run are normal. To get stable results it is good practice to average several runs. Several common programs such as Microsoft Excel can create averages automatically for you.
  94. * If you compare results between different PC's, please keep in mind that the accuracy depends on the accuracy of the PC clock. This applies to all software that does time measurements on a PC.
  95. * Under normal conditions the processor speed does not influence the measured response times. Only if the PC is so slow that the web page rendering of the browser is slowed down will the CPU speed have an influence on the measured response time. iMacros response time measurements always reflect the true user experience as they are measured using a real browser and the original browser plug-ins such as Macromedia Flash Player or SUN Java runtime.
  96. * On very '''complex web applications''' it can happen that a STOPWATCH command around a URL GOTO command correctly measures the time for a page to open, but stops the time measurement when the page is still loading and displaying "Loading". In such a case, please use a '''[[Web_Testing#Q:_How_can_I_search_for_a_specific_keyword_on_a_web_page.3F|keyword check]]''' (e. g. with a [[TAG]] or [[IMAGESEARCH]]) command to check that the page is loaded completely. This way you can measure the exact time from page access, to the completion of the page load.
  97. Example: Instead of
  98. STOPWATCH ID=Firstpage
  99. URL GOTO=http://demo.imacros.net/Automate/FlashDemo
  100. STOPWATCH ID=Firstpage
  101. Please use:
  102. STOPWATCH ID=Firstpage
  103. URL GOTO=http://demo.imacros.net/Automate/FlashDemo
  104. IMAGESEARCH IMAGE=flashEnter.bmp CONFIDENCE=90
  105. STOPWATCH ID=Firstpage
  106. === How to Measure Browser Rendering Time ===
  107. To measure ''only'' the in-browser rendering time of your site, simply test the website via a local intranet connection or directly on the web server. This sets the page load time effectively to zero, thus any delay measured by iMacros is the browser rendering time of your web application.
  108. === How to Use iMacros with JMeter for Load and Performance Testing ===
  109. To use iMacros with JMeter you do not need to install any plug-in. All you need is to create a script to control iMacros, and build a Test Plan in JMeter that launches the script.
  110. The following iMacros blog post gives more in-depth information on how to do it:
  111. * '''[http://imacros.net/imacros-and-jmeter Load and Performance Testing: How to Use iMacros with JMeter]'''
  112. ==Regression Testing [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]==
  113. Regression testing with iMacros is easy and very flexible. Please this [[Web_Testing#Q:_How_can_I_search_for_a_specific_keyword_on_a_web_page.3F|Regression Testing FAQ]] and the [[Web_Testing#Reporting|Reporting]] options.
  114. == Table-Driven Testing ==
  115. Table-driven testing, also known as keyword-driven testing or action-word testing, is a software testing methodology for automated testing that separates the test creation process into two distinct stages: a planning stage, and an implementation stage.
  116. It is an easy-to-use and very flexible form of data-driven testing. The difference is that the test case is contained in the set of data values and not embedded or "hard-coded" in the test script itself. The script is simply a "driver" (or delivery mechanism) for the data that is held in the data source.
  117. A more complex keyword (a combination of keywords into a meaningful unit), e.g. logging in.
  118. {| class="wikitable"
  119. !User
  120. !Password
  121. !Selection1
  122. |-
  123. | Tim
  124. | 65665
  125. | USD
  126. |-
  127. | Tom
  128. | 67%&PK
  129. | EURO
  130. |-
  131. | Jack
  132. | ยง$$$$6565
  133. | YEN
  134. |-
  135. | Maya
  136. | mypwdiseasy
  137. | USD
  138. |-
  139. |}
  140. '''iMacros has built-in support for table-driven testing''' with its ability to read all [[csv]] formatted files (tables). No additional coding or scripting is required. You can use any numbers of columns, and all kinds of column content is supported (including full Unicode support). The number of table columns is automatically detected.
  141. For more details, please see [[Form_Filling#Input_from_Comma_Separated_Data_.28CSV.29_File|Input from Comma Separated Data File]] and the documentation for the [[!COLn]] and [[!DATASOURCE]] variables. They are used to merge the input table data with the testing script (macro). iMacros includes the [[Demo-Loop-Csv-2-Web]] macro that demos this feature.
  142. ==Load Testing [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]==
  143. Most load testing tools simulate users at the HTTP layer - simulating only the traffic that is generated by the browser, rather than simulating the entire browser.
  144. iMacros is different. iMacros emulate user behavior, making AJAX, Flash, Flex, Java and Silverlight load testing trivial. It works by testing the complete web application inside the browser (Internet Explorer (IE), Firefox, iMacros Browser) and gives you 100% realistic testing data to accurately reflect true end-user experiences. This includes load testing websites with AJAX, Flash, Flex, Silverlight or Java applets.
  145. This approach requires that each simulated user has his own browser instance. You can run several instances of iMacros at once, thus simulating concurrent users. This approach works very well for 1...50 users per average PC. The limit is only the number of IE or Firefox instances than can run on your machine. As a rule of thumb, simulating up to 50 concurrent users on a single machine is no problem. You can use the low cost [http://imacros.net/store/compare-versions iMacros Player Unlimited User license] to install iMacros on many machines to increase the load at no extra cost ('''Unlimited''' Virtual Users). As an example, if you have access to five machines, you can generate a load of up to 250 concurrent users.
  146. You can use the STOPWATCH command to measure the web application performance in great detail during your load test.
  147. Note that the number of '''concurrent''' users that you need to simulate for load testing is very small compared to the number of monthly visitors:
  148. concurrent = (visits_per_month * average_time_on_site) / (3600 * 24 * 30)
  149. So if you e.g. have 30,000 visits per month, and the average visitor
  150. spends 3 minutes on your site (180 seconds), it means your average
  151. number of concurrent visitors will be (30000 * 180) / (3600 * 24 * 30) =
  152. 2.048 or '''just over 2 visitors'''. However, this is the *average* number of
  153. visitors your site will have. Usually, peak hour traffic will be a lot
  154. higher and low traffic hours a lot lower. How much higher peak traffic
  155. is than average traffic can vary depending on what site you have, just
  156. as average time on site will vary depending on the type of site you have.
  157. (Observe also, that it is important to use the total number of visits -
  158. not the number of unique visitors - when calculating average number of
  159. concurrent visitors).
  160. iMacros blog post:
  161. * '''[http://imacros.net/imacros-and-jmeter Load and Performance Testing: How to Use iMacros with JMeter]'''
  162. == Testing AJAX websites ==
  163. Ajax-driven or JavaScript-heavy sites often require different strategies than when testing a regular site: elements appear, disappear and change at any time. Because of its built-in "intelligence" iMacros can automate many AJAX based websites using standard HTML based TAG commands. And it can '''automate absolutely all AJAX elements with [[DirectScreen Technology]]'''. This allows in-browser testing of even the most complicated AJAX elements, including sliders and drag & drop activity.
  164. Related Demo-Macros:
  165. *[[Demo-AJAX-Drag-Drop]]
  166. *[[Demo-AJAX-Tree]]
  167. Forum posts:
  168. * [http://forum.imacros.com/viewtopic.php?t=757 How to handle AJAX]?
  169. * [http://forum.imacros.com/viewtopic.php?f=14&t=6107&p=17197#p17197 Load and Performance testing of AJAX pages]
  170. ==Website Monitoring==
  171. iMacros is ideally suited for web performance monitoring and synthetic user monitoring (transaction monitoring, testing websites with real browsers). For this purpose the iMacros team has created the popular AlertFox [http://alertfox.com website monitoring] service. Give it a try and sign up for a [http://alertfox.com/free-website-monitoring/?ref=wiki free website monitoring] account. And continuously test and measure your website performance with your iMacros macros.
  172. == Reporting [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]==
  173. iMacros has several reporting options. You can use the default reports or use the iMacros scripting features to create any kind of report.
  174. 1. Global logfile (lists any issues that might have occurred, such as website not available) with date and time.
  175. 2. [[!FILELOG|Per macro reports]], same as #1, but per macro.
  176. 3. [[Web_Testing#Response_Time_Measurements|Performance reports]] with the [[STOPWATCH]] command
  177. 4. [[Browser_Automation#Web_Site_Screenshot|Screenshots]]: iMacros can take screenshots during the iMacros run, so you can see what went wrong (e.g. an image missing or formatting issue).
  178. 5. '''Custom reports:''' You can '''create any kind of report''' via the Scripting Interface. This includes writing the test results to a log file (e. g. [[Combine-Macros.vbs]]) or [[Browser_Automation#Web_Site_Screenshot|taking a screenshot]] of the web browser after an [[Error-Codes|error]] has occurred. You can also use this interface to connect iMacros directly with any kind of software or program, e. g. test planning software.
  179. If you have any reporting requirement that is not covered here, [http://imacros.net/support/professional-services/ please let us know].
  180. == Change User Agent ==
  181. Related example: Set-User-Agent.vbs (VBS script)
  182. Every time you access a web site the browser you use sends a string to the web server containing information about your operating system and the browser you are using. This string might, for example, look like this:
  183. Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
  184. Sometimes it is desirable to pretend to be a different user agent because some web sites change in behaviour or appearance depending on the user agent. iMacros can simulate all user agent strings with the -useragent command line switch. The command line switch can also be used in iimInit command of the the Scripting Interface:
  185. iret = iim1.iimInit ("-useragent ""Nokia6230/2.0+(04.43)""") [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]]
  186. If your user agent contains spaces, please use double quotes ("") around it.
  187. You can see the current user agent of iMacros at http://www.iopus.com/imacros/demo/v6/user-agent.htm
  188. In iMacros for Firefox please use the following command inside the macro:
  189. SET !USERAGENT "New User Agent here". [[Image:Ff-icon.png|Firefox]]
  190. So with iMacros for Firefox the user agent can be changed during the macro runtime. With Internet Explorer, the user agent is defined when Internet Explorer is started.
  191. == Web Testing FAQs==
  192. === Q: How can I detect if an error page is loaded? ===
  193. The [[URL]] command itself can not distinguish between loading the "real" web page and an error page (ASP.NET error page, SQL error page, or [[404]] error page). Because in all these cases the (error) web page itself loads fine (no timeout).
  194. But there is a simple solution: Use the [[TAG]] command to [[Web_Testing#Keyword_Search_with_TAG|check for a keyword]] or [[Web_Testing#Q:_I_want_to_test_that_certain_images_will_show_up_on_my_site_when_a_page_is_loaded.|image]] that exist only on the right (non-error) page.
  195. Please see the next FAQs on how to do such a keyword check.
  196. === Q: How can I search for a specific keyword on a web page? ===
  197. When parsing a web site you want to find out if a certain word exists on a web page to trigger further action (like saving the web page, printing the page or running the next macro). This is also called ''keyword assertion'' or ''regression testing''.
  198. There are many applications of the keyword search feature. For example tracking your search engine ranking, observing a (financial) news web site, get feedback on a failed login, watching web pages for changes or even monitoring trademark infringements automatically.
  199. If the keyword does not exist, iMacros retries the keyword search automatically every second until the [[!TIMEOUT]] value is reached. If the keyword is still not found, iMacros reports an error.
  200. The automatic retry makes web testing [http://forum.iopus.com/viewtopic.php?f=7&t=757 websites with AJAX] easy. For standard websites, you can also combine a keyword search with the [[REFRESH]] command to wait until a page changes. If you want to test without retry, please use ''SET !TIMEOUT 1'' before the keyword search.
  201. iMacros offers three options for keyword search (keyword assert):
  202. 1. TAG command
  203. 2. TAG... EXTRACT command
  204. 3. IMAGESEARCH command
  205. Please see below for more details on each option. We also created the "Demo-Keyword-Check.iim" example macro.
  206. <small>[[Keyword Search | (direct link to this FAQ)]]</small>
  207. ==== Keyword Search with TAG ====
  208. The TAG command searches for a HTML tag inside the web page. If found, it clicks on it. But TAG can also search for any kind of text on a web page. Thus, any TAG command is automatically a keyword assert command. For example
  209. TAG POS=1 TYPE=STRONG ATTR=TXT:*iMacros*
  210. searches for the word iMacros enclosed by the STRONG HTML tag. If you want to search for text regardless of the format, i.e. the enclosing HTML tag, please use the wildcard character * instead of a HTML tag:
  211. TAG POS=1 TYPE=* ATTR=TXT:*iMacros*
  212. This command is the same as above, but this time the command ignores the formatting of the keyword. This command takes longer, as iMacros needs to scan the complete page, not only certain html tags.
  213. You can also "invert" the keyword search and '''generate an error if the keyword is found''' on the page:
  214. TAG POS=1 TYPE=* ATTR=TXT:*iMacros* CONTENT=EVENT:FAIL_IF_FOUND
  215. As the event suggests the TAG command will now generate an error if it succeeds.
  216. '''Use of timeout when looking for text:''' There are two kinds of timeouts used by iMacros:
  217. *1. iMacros waits for the page to load up to [[!TIMEOUT]] seconds. The default is 60s.
  218. *2. After the page is loaded, iMacros checks for the text to appear. If the text is ''not'' found, it waits one second and ''re-checks the page!''. It does this until the "TAG timeout" value is reached. It is always 1/10 of the regular timeout (default is 6s).
  219. Related forum post: [http://forum.iopus.com/viewtopic.php?f=23&t=8752 Keyword search / wait until keyword is found]
  220. ==== Keyword Verification by Extracting Text====
  221. You can use the EXTRACT feature and make the keyword the extraction anchor. The general idea is to try and extract a certain piece of information and then check if the extraction result is the Extraction Anchor Not Found (#EANF#) message.
  222. Example: We want to find out if the words "Order completed" are displayed on a web page. If yes, we want to print the page. To search the web page for the test phrase, create a macro called mysearch, which only has two lines:
  223. VERSION BUILD=6140125
  224. TAG POS=1 TYPE=* ATTR=TXT:*Order<SP>completed* EXTRACT=TXT
  225. In this example we are searching the web page for the first occurrence (POS=1) of the keyword "Order completed". If the message #EANF# is returned then the keyword was not found as the keyword is the data extraction anchor. If the keyword was found then the EXTRACT command returns the complete text of the found HTML tag. In our example this could be "Software Order completed".
  226. To print the web page create a macro called print_this. It has only two lines:
  227. VERSION BUILD=6140125
  228. PRINT
  229. To connect both macros together create a small Windows script:
  230. set iim1= CreateObject ("imacros")
  231. iret = iim1.iimInit()
  232. iplay = iim1.iimPlay("mysearch")
  233. extracted_text = iim1.iimGetLastExtract(1)
  234. 'test if keyword appeared on website.
  235. If iplay = 1 Then
  236. If instr (extracted_text, "#EANF#") > 0 Then
  237. MsgBox ("Sorry, keywords not found")
  238. Else
  239. iplay = iim1.iimPlay("print_this")
  240. End If
  241. End If
  242. If iplay < 0 Then
  243. MsgBox "Error!"
  244. End If
  245. Note: The same procedure can be used to look for several keywords on a page, for example "cat", "dog" and "mouse":
  246. The solution is to use several EXTRACT commands. So in the macro use:
  247. TAG POS=1 TYPE=* ATTR=TXT:*mouse* EXTRACT=TXT
  248. TAG POS=1 TYPE=* ATTR=TXT:*cat* EXTRACT=TXT
  249. TAG POS=1 TYPE=* ATTR=TXT:*dog* EXTRACT=TXT
  250. In the script you can look at each array element to see if they keyword was found:
  251. iplay = iim1.iimPlay("wsh-extract-rate")
  252. If iplay = 1 Then
  253. If iim1.iimGetLastExtract(1) <> "#EANF#" Then MsgBox "Keyword CAT found!"
  254. If iim1.iimGetLastExtract(2) <> "#EANF#" Then MsgBox "Keyword DOG found!"
  255. If iim1.iimGetLastExtract(3) <> "#EANF#" Then MsgBox "Keyword MOUSE found!"
  256. End If
  257. ==== Keyword Search with IMAGESEARCH ====
  258. You can use the [[IMAGESEARCH|IMAGESEARCH]] command to look for keywords or keyimages. Thus, instead of a text you supply an image of the word:
  259. Example (Image of the word "iMacros"): imacros
  260. The advantage of this command is that it '''works on any type of web page, including Flash, Java, Silverlight or ActiveX controls'''. With these applets you can not extract the displayed data as ''text'', but only as image. To verify that the correct text is displayed, create a small image of this text and then search for it with [[IMAGESEARCH]]. In the [[Demo-ImageRecognition]] macro this approach is used to validate the Flash calculator result.
  261. We also recommend to take a screenshot of the complete browser with [[iimTakeBrowserScreenshot]] when your macro detects a page error. This is an excellent method to log such issues for later discussions with your colleagues.
  262. For more details please see the [[Image_Recognition_Plugin|Image Recognition Plugin]] chapter.
  263. === Q: I want to test that certain images will show up on my site when a page is loaded. ===
  264. (a) Check that an image is present
  265. The Save Item function includes an image checkpoint. If a image is missing, an error will occur. Example:
  266. CLEAR
  267. TAG POS=1 TYPE=IMG ATTR=TXT:*bee.jpg CONTENT=EVENT:SAVEITEM
  268. TAG POS=1 TYPE=IMG ATTR=TXT:*shark.jpg CONTENT=EVENT:SAVEITEM
  269. This macro will download two images. If one image is missing on the web page the macro stops with an "image not found" error. To make sure that the missing image is not stored in the browser cache it is recommended that you use the CLEAR command before this test.
  270. This technique is also recommended if you are automating or testing web sites with complex frames. To make sure a specific frame is completely loaded do the above test for a specific image in this frame. iMacros will wait at the TAG.....EVENT:SAVEITEM command until this image appears.
  271. The method is easily implemented if you have information about the image such as its own URL, the link URL or the alternative text. If all you have is the image itself use the IMAGESEARCH command of the Image Recognition Plugin.
  272. (b) Check the content of an image
  273. Please use the [[IMAGESEARCH]] command if you need to verify the content of an image.
  274. === Q: Does iMacros support checkpoints? ===
  275. Yes! Please see the [[Checkpoints]] page for more details.
  276. === Q: Does iMacros support multiple checkpoints in one macro? ===
  277. By design, a macro stops when an error occurs (see [[Checkpoints|checkpoints]]). To verify multiple checkpoints there are two strategies:
  278. 1. Split the task in several sub macros, with one checkpoint per macro. A macro can be very small, and even contain only one line. Example:
  279. i = iim1.iimPlay ("Checkpoint1")
  280. if i < 0 then msgbox ("Checkpoint 1: Macro reports error.")
  281. i = iim1.iimPlay ("CODE:TAG POS=2 TYPE=A ATTR=TXT:*Download* ")
  282. if i < 0 then msgbox ("Checkpoint 2: Text not found.")
  283. i = iim1.iimPlay ("CODE:IMAGESEARCH IMAGE=result.bmp CONFIDENCE=90")
  284. if i < 0 then msgbox ("Checkpoint 3: Image not found.")
  285. 2. If you only need to verify text you can also use the [[Data Extraction]] features of iMacros to return the information to your script, and then process the result according to your business requirements.
  286. === Q: How to use iMacros with 3rd party tools? ===
  287. iMacros can be integrated with almost any 3rd party tools (e.g. NUnit or SpiraTeam testing frameworks).
  288. For the integration you can use
  289. * the powerful iMacros [[Web Scripting|Scripting Interface]]. This is the recommended method as it offers detailed [[Web_Scripting#Error_Handling|error reporting]] features and the option to send test macros to the browser via [[iimPlay]] ("CODE:...")).
  290. * the very easy to use iMacros [[Sample_Code#Batch_Files|command line]] interface.
  291. Related Case Study: [http://www.iopus.com/imacros/reviews/#agilent Agilent Technologies] uses the iMacros Scripting Interface to integrate iMacros with their WebTrans Software/QoS Manager. The QoS Manager is a powerful, dedicated Java based web testing and web monitoring framework used by major telcoms.
  292. If you have questions about integrating iMacros with a specific third party software, please ask our [http://www.iopus.com/service/support/ tech support].
  293. === Q: How to invoke 3rd party tools from iMacros? ===
  294. iMacros can interface with '''any''' 3rd party tool. To achieve this,'' call both, iMacros and the 3rd party tool from a script''. [[Sample Code|Any programming language]] can be used for this via the powerful iMacros [[Web Scripting]] Interface.
  295. All programming languages have slightly different methods to run programs, but the basic idea is always the same. Here is an example for VB Script:
  296. Example:
  297. 'Run iMacros Regression Test
  298. iErrorCode = iim1.iimPlay ("TestShoppingCartMacro")
  299. 'Call 3rd party tool
  300. Set objShell = CreateObject("WScript.Shell")
  301. iErrorCode = objShell.Run "3rdPartyTool.exe /cmd1 /cmd2"
  302. 'You can also run Windows command line tools (MSDOS, Batch files,...) directly
  303. iErrorCode = objShell.Run("ping www.mywebsite.com",,True)
  304. If you have questions about a specific third party software, please ask our [http://www.iopus.com/service/support/ tech support].
  305. === Q: How does iMacros use variables? ===
  306. Please see the answer to the question: [[Web_Testing#Q:_Can_iMacros_run_data_driven_tests.3F|Can iMaros run data driven tests?]].
  307. === Q: Is there any way to verify if any javascript errors have been thrown? ===
  308. Yes! You can run a regression test and ensure no errors came out of Javascript. To log Javascript error messages, please make sure that the display of Javascript error message is enabled. To enable it, '''un'''check the "Disable Script Debugging" option in the Internet Explorer Settings Dialog. These settings are also used by the iMacros Browser.
  309. [[Image:Report-javascript-error.png|none|thumb|300px|
  310. Extracting the text of a Javascript error message.]]
  311. For more details please see the [[Browser_Automation#Page_Errors|Page Errors]] chapter and [[ONERRORDIALOG]]. Related forum post: [http://forum.iopus.com/viewtopic.php?f=2&t=5134&p=14224#p14224 Take screenshots when Javascript errors occur.]
  312. === Q: Can iMacros run data driven tests? ===
  313. Yes! iMacros can read data and use it to fill forms and/or make special decisions during the macro run. There are two methods to connect iMacros with data sources.
  314. 1. Read [[csv|CSV]] files directly. iMacros can import data directly into the <nowiki>{{!COL1}}, {{!COL2}},...</nowiki> [[!COLn|variables]]. Please see the [[Demo-Loop-Csv-2-Web]] macro.
  315. 2. Use the Scripting Interface to [[Sample_Code#Database_Access|connect to any database]].
  316. 3. Use the Scripting Interface to [[Sample_Code|call iMacros from any programming or scripting language]].
  317. === Q: What effect does iMacros itself have on web application response measurements? ===
  318. The overhead of iMacros itself is very thin. On a 3 GHz Pentium each macro step takes only about 20 ms (0.02s) of processing time. If you compare this to the average page response time the delay caused by iMacros itself is typically much less than 2%. Note that a few commands need more processor time, for example the CLEAR, IMAGESEARCH or IMAGECLICK commands.
  319. Since the iMacros Browser is an IE-compatible browser, realistic viewer experience results are guaranteed. For example, your performance measurement results include the browser rendering time.
  320. === Q: How can I set up a 24 hours a day, 7 days a week (non-stop) operation with iMacros? ===
  321. Many applications of iMacros require continuous operation of the software. Examples are the use of iMacros as part of payment gateway, extracting large volumes of information or web testing applications in general.
  322. Problem:
  323. iMacros has the ability to remotely control the web browser and a wide variety of third-party browser plug-ins, such as Java virtual machine (Java applets), Adobe Acrobat Reader (PDF viewer), Macromedia Shockwave (Flash applets) and many others. By design most of these controls are not intended for 24x7 operations and running them repeatedly for several days can lead to undesirable effects, such as increased memory consumption ("memory leaks").
  324. Solution:
  325. The Scripting Interface is a compact and reliable component that controls the iMacros browser and thus, all its plug-ins. The Scripting Interface was designed to automate web testing and at the same time to compensate for problems of the Windows Internet components used by the iMacros browser and third-party browser plug-ins.
  326. [[Image:7x24.png|frame|Picture 1: Stable CPU and memory usage over time running the sample code listed below in part (b) with the "Demo-Flash" macro. The left part is a task manager snapshot taken on day 1 and the right part is taken on day 30. The snapshots were taken on a Windows Server 2003 with 2 GHz CPU and 512 MB Ram. Nowadays we recommend using Windows 2008 and better.]]
  327. The image shows stable CPU and memory usage over time running the sample code listed below with the "Demo-Flash" macro. The left part is a task manager snapshot taken on day 1 and the right part is taken on day 30. The snapshots were taken on an old Windows Server 2003 with 2 GHz CPU and 512 MB Ram. Nowadays we recommend using Windows 2008 and better.
  328. A periodic restart of the server is not required. However, as with any server application in general you should make sure that the application restarts correctly after the machine is rebooted or reset.
  329. If you need to repeat a certain macro, for example five million times, do not start a single browser instance and use the Play (Loop) button. Instead use the Scripting Interface for the loop. In VBS code this looks like:
  330. 'Sample code A
  331. Set iim1= CreateObject ("imacros")
  332. For m = 1 to 5000000
  333. iret = iim1.iimOpen()
  334. iret = iim1.iimPlay("macro1")
  335. iret = iim1.iimClose()
  336. Next
  337. This command sequence closes the browser after each macro and thus avoids browser memory leaks. Even if the browser or one of its plug-ins "hangs" or"crashes", the Scripting Interface is not influenced by this and will open a fresh browser instance and continue to work. However, closing and re-opening the browser (as the above example does) takes a few seconds on an average PC. So if processing speed is important for your application you can split this task in two loops and use iimExit only, for example, every 1000th loop to save time.
  338. 'Sample code B
  339. Set iim1= CreateObject ("imacros")
  340. For m = 1 to 5000
  341. iret = iim1.iimOpen()
  342. For n = 1 to 1000
  343. iret = iim1.iimPlay ("macro1")
  344. Next
  345. iret = iim1.iimClose()
  346. Next
  347. '''Notes on Running Many Concurrent Instances'''
  348. Web browsers typically aren't designed for high volume usage such as attempting to run 20 or more concurrent browser instances. A whole host of issues can ensue, from memory leaks to performance degradation and system hangs. This is why we have provided this wiki section to serve as a best practices guide. We encourage you to share your own experiences with our tech support department so that we can continue to spread the knowledge and everyone benefits!
  349. In our testing and experience, CPU power tends to be the primary limiting factor, more so than the amount of RAM in the system. Starting a new browser instance (calling iimOpen) is very CPU intensive, so you want to make sure that you aren't attempting to start multiple browser instances all at the same time or otherwise the system will bog down and may become unresponsive.
  350. The best thing to do is to sequentially launch one instance at a time until all are started, and then commence with playing macros in each instance simultaneously. Of course you should periodically restart the browser instances to avoid memory leaks by shutting them down (with iimClose) and reopening them sequentially again.
  351. Related chapter: [[Web_Scripting#How_to_run_iMacros_unattended|How to run iMacros unattended]].
  352. Related case study: [http://www.alertfox.com/?section=TourView AlertFox] runs iMacros non-stop every day as core part of their unique [http://www.alertfox.com website transaction monitoring service]:
  353. AlertFox runs iMacros Enterprise Edition on the [http://wiki.alertfox.com/Monitoring_Server backend] (iMacros Enterprise Bundle). The backend consists of Windows 2003 R2 and Windows 2008 servers (both 32-bit and 64-bit). '''1000s of browsers''' are opened and closed all the time. All browsers are controlled by the iMacros [[Web Scripting]] interface and [[iimRunner]]. The website and test services are created in C++, C# and ASP.NET. The database is MS SQL 2005.
  354. Tip: You can use a simple [[Taskkill|batch file to remove crashed browser instances]]. These crashes are caused by the automated browser itself, not iMacros (if you suspect that iMacros causes a crash, please contact our tech support!).
  355. (tinyurl to this FAQ: http://tinyurl.com/6xl8h6)

comments powered by Disqus