Contributions
How can I specify the AVRO key for Kafka messages in ReadyAPI?
Hello! I am trying to send a Kafka message via ReadyAPI. The message arrives, however, Kafka reports an error about missing key. More exactly: Error serializing Avro message Incompatible schema {<the scheme of key>} with refs [] of type AVRO for schema "string" If I look with 'UI for Apache Kafka' at messages accepted by the system (same topic etc.) I see that messages always have three 'attributes': Value: This is the message itself (JSON) Headers: This is afortunatelly just an empty JSON object {}. So, we don't need headers. Key: This is a specific value (a JSON containing a single value) for each message, easely computed using a part of the message itself. In ReadyAPI you specify the 'Value' of the message via 'Data'. The question is: How can I specify the AVRO key for Kafka messages in ReadyAPI? The specification of the key as meta data (i.e. Send Data / Metadata / Name = Key or key, Type Kafka) does not work. Thank you very much for your time. Regards, Roberto154Views0likes0CommentsTestComplete Gherkin Autocompletition. Making sure that I don't define 2 steps for the same purpouse
This idea is based on my post:TestComplete Gherkin Autocompletition. Making sure... - SmartBear Community Thanks torraghvanifor suggest me to create a new idea for this topic. Here we go: We work with BDD in our project. More precisely, we use Gherkin in TestComplete to define, align and automate scenarios. We want to avoid defining multiple steps for the same purpose because this may rise in unintentionally doubling code. Example: Assume, the following steps have the same meaning: When I type "Hugo" in the field "name" When I type "Hugo" in field "name" When I type "Hugo" field "name" When I type "Hugo" on the field "name" When I type "Hugo" on "name" Despite the fact, that you may encounter a situation, in which those sentences means different things. In our case, they don't. Simply assume all this steps mean the same:Type something in a field. Instead of having different variants of thesamestep,it might be useful to get a hint from TestComplete that such a similar step already exists. That's why I think, we need some kind of autocompletion for Gherkin. Thanks for your replys! Regards, RLRE PS: VERY important: Please add following Idea Labels to the ideas creation page:BDD Tests, Script Extensions, Script Tests, Test Creation200Views0likes0CommentsTestComplete Gherkin Autocompletition. Making sure that I don't define 2 steps for the same purpouse
Hello Community! We work with BDD in our project. More precisely, we use Gherkin in TestComplete to define, align and automate scenarios. We want to avoid defining multiple steps for the same purpose because this may rise in unintentionally doubling code. Example: Assume, the following steps have the same meaning: When I type "Hugo" in the field "name" When I type "Hugo" in field "name" When I type "Hugo" field "name" When I type "Hugo" on the field "name" When I type "Hugo" on "name" Despite the fact, that you may encounter a situation, in which those sentences means different things. In our case, they don't. Simply assume all this steps mean the same: Type something in a field. Instead of having different variants of the same step,it might be useful to get a hint from TestComplete that such a similar step already exists. That's why I was thinking about some kind of autocompletion for Gherkin. There may be a better way to avoid doubling steps, unless of course you know all the steps inside out, which will not be the case for all contributors in our project. Is there an extension or even a configuration setting in TetsComplete for autocompletition in Gherkin? Our alternatives so far are: - Work with Pull requests to review each others feature files // this may be to late - Create and keep a list (outside TestComplete) of existing steps with their meaning. // Update effort is high, I think. I.e. none of the current ideas is satisfactory. Maybe your ideas are better. Thanks for that! Regards, RLRE350Views0likes1CommentRe: How can I get the whole image of a canvas object?
First of all:Thanks to rraghvanifor the hints that put me on the right track. Here is commented code with solution: // File names const fileNameRoot = "C:\\Temp\\Canvas"; const fileNameHtml = fileNameRoot + ".html"; const fileNamePng = fileNameRoot + ".png"; const fileNameJpeg = fileNameRoot + ".jpeg"; const fileNameWebp = fileNameRoot + ".webp"; // get the page objekt - adapt parameters as needed... var pageObj = Sys.Browser(Project.Variables.Browser).Page(Project.Variables.HomePage + "*"); // get the canvas object - we use here a xpath expression. var xPath = "//canvas[contains(@class, 'shapes')]"; // adapt as needed var canvasObj = pageObj.FindChildByXPath(xPath); // following fails to get hidden canvas picture partitions // var pictureCanvas = canvasObj.Picture(0,0,-1,-1,false); ///////// // Get canvas picture using canva native method toDataURL(). See: // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL // The return value of toDataURL() is ready to embed in a html page and // contains 'data:image/png;base64' image at the begining var imagePNGAsBase64WithPrefix = canvasObj.toDataURL("image/png", 1.0); // 1.0 not needed // JPEG Contains 'data:image/jpeg;base64,' and so on. var imageJPGAsBase64WithPrefix = canvasObj.toDataURL("image/jpeg", 1.0); // 1.0 == no compression var imageWEBPsBase64WithPrefix = canvasObj.toDataURL("image/webp", 1.0); // we need to dropp prefixes for image file creation const prefixHTML_imagePng = "data:image/png;base64,"; const prefixHTML_imageJpg = "data:image/jpeg;base64,"; const prefixHTML_imageWbp = "data:image/webp;base64,"; // dropp the prefixes var imagePNGAsBase64NoPrefix = aqString.Replace(imagePNGAsBase64WithPrefix, prefixHTML_imagePng, "", false); var imageJPGAsBase64NoPrefix = aqString.Replace(imageJPGAsBase64WithPrefix, prefixHTML_imageJpg, "", false); var imageWEBPsBase64NoPrefix = aqString.Replace(imageWEBPsBase64WithPrefix, prefixHTML_imageWbp, "", false); // Create html file showing the images var oFile = aqFile.OpenTextFile(fileNameHtml, aqFile.faWrite, aqFile.ctANSI, true); oFile.Write("<!DOCTYPE html><html><head><title>Canvas picture as PNG, JPEG and WebPage-Image</title></head><body>"); oFile.Write("<img style='width:100%; height:100%;' src='" + imagePNGAsBase64WithPrefix + "'/>"); oFile.Write("<img style='width:100%; height:100%;' src='" + imageJPGAsBase64WithPrefix + "'/>"); oFile.Write("<img style='width:100%; height:100%;' src='" + imageWEBPsBase64WithPrefix + "'/>"); oFile.Write("</body></html>"); oFile.Close(); // Attach the html file to log Log.Link(fileNameHtml, "HTML-File containing image from canvas only."); ////////////////////////////// // Image file creation // Create png-File directly var ps = dotNET.System_Management_Automation.PowerShell.Create(); var psCmd = "[IO.File]::WriteAllBytes('" + fileNamePng + "',[Convert]::FromBase64String('" + imagePNGAsBase64NoPrefix + "'))"; // log the actual command for fun. Log.Message("Power-Shell command", psCmd); ps.AddScript(psCmd); // 'type' it to PowerShell var results = ps.Invoke(); // Run. // Attach picture file to Log Log.File(fileNamePng, "Canvas picture as PNG."); // Create JPEG-File directly psCmd = "[IO.File]::WriteAllBytes('" + fileNameJpeg + "',[Convert]::FromBase64String('" + imageJPGAsBase64NoPrefix + "'))"; ps.AddScript(psCmd); results = ps.Invoke(); Log.File(fileNameJpeg, "Canvas picture as JPEG"); // Create WEBP-File directly psCmd = "[IO.File]::WriteAllBytes('" + fileNameWebp + "',[Convert]::FromBase64String('" + imageWEBPsBase64NoPrefix + "'))"; ps.AddScript(psCmd); results = ps.Invoke(); Log.File(fileNameWebp, "Canvas picture as WEBP"); /////////////////////////////// // Compare with file from Disk var pictActual = Utils.Picture; pictActual.LoadFromFile(fileNameJpeg); // pictExpected is the name of expected result file (created by first run, for example). var pictExpected = Utils.Picture; pictExpected.LoadFromFile(fileNameRoot + "_Expected.jpeg"); // the comparisson var bRes = pictActual.Compare(pictExpected) if (bRes) { Log.Checkpoint("Canvas picture as expected!"); } else { Log.Error("Canvas picture don't meet expected result"); } A last remark on the files created: Perhaps we may use toBlob() method instead of toDataUrl() to avoid conversions. (I haven't try it yet.) Good luck!694Views1like1CommentRe: Web Testing running javascript code from page: can not access to members
rraghvanithank you for your suggestions. I just had a session with our development and tried a few things afterwards: The allShapes object is attached to the window object of the page. I.e. something like windows.allShapes should be possible. In the Edge console I see a method getShapeById("someID"), which can be called directly or with windows.getShapeById("someID") and returns a result. I.e. both the call windows.allShapes and windows.getShapeById("someID") should work. However, I can't get the "right" window object in TestComplete. The following object is defined: var theWindow = pageObj.contentDocument.Script.Window; // pageObj.contentDocument.window returns the me same object as with capital letter However, following fails (both of them) var shape21P = theWindow.getShapeById("21P"); var allShapes = theWindow.allShapes; because unknown method or member respectivelly . The page is definitely written with Angular. There are no protected members or methods (neither of the window object nor of other things). Any idea how I could access the window object from TestComplete? Thank you very much!670Views1like0CommentsHow can I get the whole image of a canvas object?
Hello all, In the web app I am testing, there is a <canvas/> object that displays as image only. The app only displays part of the image because this image is almost always way too big to display. The user can scroll in all directions to view the other regions of the image. I want to use TestComplete to save the entire image so that I can make image-level comparisons. Using pageObj.PagePicture(), as expected, is not the solution because it only shows the page of the app. Calling canvasObj.Picture(0,0,-1,-1,false) returns an image of the correct size, but of what is currently there on the screen (Including black areas for the part of the image that is outside the PC monitor). How can I get the whole image of a canvas object at once? Notes / More info: 1) If possible, I would like to avoid scrolling in the automation and shooting multiple images that I then have to 'glue' together. For similar reasons, I would like to avoid using region checkpoints for image parts if possible. 2) Development will give me a way to read the data I want the application to show in the image from the page's javascript via get methods. However, this is an additional nicety. I really need to check the displayed image, though. (!) It is not enough that the application sends the correct data to the client: The application must also display this data appropriately on the image. Testing the image directly is an important requirement of the client. Therefore I need to read the whole image of the canvas. Thank you very much for your time!Solved849Views0likes4CommentsRe: Web Testing running javascript code from page: can not access to members
Hellorraghvani, thank you very much for your effort. Unfortunatelly, the modules defined i.e. loaded in the app have names that are not allowed as identifier in javascript, i.e. something like main.308a3c81de0bcf749. Using eval with double quotes fails too. Here my trys: var mainMod00 = pageObj.contentDocument.Script.eval("main.308a3c81de0bcf749"); var mainMod01 = pageObj.contentDocument.Script.eval("'main.308a3c81de0bcf749'"); var mainMod10 = pageObj.contentDocument.Script.eval("eval('main.308a3c81de0bcf749')"); var mainMod11 = pageObj.contentDocument.Script.eval("eval(main.308a3c81de0bcf749)"); All the mainMod* vars are undefined (no allShapes at undefined). Really weird things, like the following: // Try to load it directly: pageObj.contentDocument.Script.eval("import { mymod } from 'main.308a3c81de0bcf749';");// ?!? var shapesReloaded0 = pageObj.contentDocument.Script.mymod.allShapes; var mainmod = pageObj.contentDocument.Script.eval("await import('main.308a3c81de0bcf749');"); var shapesReloaded1 = mainmod.allShapes; unfortunately do not work either. Any other ideas? Thank you very much.700Views1like0CommentsWeb Testing running javascript code from page: can not access to members
Hello! I am testing a web app in Edge. When I start the web app by myself in Edge, open the developer tools with F12 and go to the console, there I can call a member called 'allShapes'. The result is an array of shape objects that the application displays, containing additional information I need to check in my tests. Following the instructions in https://support.smartbear.com/testcomplete/docs/app-testing/web/common-tasks/javascript.html#HowTo, I tried the following: var shapes0 = pageObj.contentDocument.Script.allShapes; var shapes1 = pageObj.contentDocument.Script.eval("allShapes;"); var shapes2 = pageObj.contentDocument.Script.$get("allShapes"); var shapes3 = pageObj.contentDocument.Script.eval("window.allShapes;"); var shapes4 = pageObj.contentDocument.Script.window.allShapes; var shapes5 = pageObj.contentDocument.Script.window.$get("allShapes"); Unfortunately, all the shapes* variables are undefined. When I look in the debugger, the contentDocument and Script objects are defined, however, allShapes and other members and methods I see in Edge's console are not visible. What can be the reason for this? What am I doing wrong? Thank you very much for your time! PS: Using TestComplete 15.31.374.7.The application in question is written with Angular.760Views1like4Comments