Contributions
Re: Script access to variables for ProjectName, KeywordTestName, etc
Why would I want to know the current keyword test name? Because I archive files when running many keyword tests. When I archive the files, I want the archive location to contain the name of the test associated with the folder contents. Imagine yourself having 100 folders from different tests and asking yourself, which is associated with KeywordTestA, KeywordTestB, or KeywordTestC. In order to name, the folder I need the name of the keyword test, not TestItem.1.6KViews0likes0CommentsRe: Ambiguous object mapping.
Try conditional mapping for the alias (Check under NameMapping in the Project Explorer). Check the process properties for your appliation in the Object explorer and find something that is the samefor you applications. Use that property as conditional property for name mapping. For instance, I use the CommandLine property for my appliation that we can launch using java.exe or javaw.exe from the same path. I have a conditional mapping where I check a process for the matching command line property and then map that process to the desired alias.1.7KViews0likes2CommentsRe: have access to the name of the current test
Here's a function that I developed. It forces TestComplete to create a test log. As far as I can tell.... Testcomplete will not generate a log before finishing a test or pausing a test.Without having a log available, finding the current keyword test name is difficult - TestComplete doesn't have a built-in method - Asking TC to save a log forces it to generate a log - the log will contain the current test name (really whatever caused the runner to start. It could be a keywork test, test item, script, etc.). Once you have create the file from a log export, you can open the file and extract the name that will appear in the test log. Function GetCurrentTestName() dim temp dim logfolderPath dim logindexFile dim indexPathFile dim templogPath dim templogfile dim templogText 'delete previous folder Call aqFileSystem.DeleteFolder(Project.ConfigPath + "\ExportedLog", true) 'testcomplete will not generate a log before finishing a test or pausing a test. 'Without having a log available, finding the current keyword test name is 'difficult - TestComplete doesn't have a built-in method - Asking TC to 'save a log forces it to generate a log - the log will contain the 'current test name log.SaveResultsAs Project.ConfigPath + "ExportedLog\templog.xml", IsXML Set templogfile = aqFile.OpenTextFile(Project.ConfigPath + "ExportedLog\templog.xml", aqFile.faRead, aqFile.ctANSI) templogText = templogfile.ReadAll templogfile.Close '<Prp name="test type" type="S" value="Log_Index_check7777"/> dim iFind1 dim iFind2 dim iFind3 dim sText1 dim sText2 sText1 = "<Prp name=" + chr(34) + "test type" + chr(34) + "type=" + chr(34) + "S" + chr(34) + "" iFind1 = InStr(templogText, "test type") sText2 = "value=" iFind2 = InStr(iFind1+1, templogText, sText2) iFind3 = InStr(iFind2+1, templogText, "/>") temp = Mid(templogText,iFind2 + len(sText2)+1, iFind3 - iFind2 - len(sText2)-2) log.message "current test name: '" + Mid(templogText,iFind2 + len(sText2)+1, iFind3 - iFind2 - len(sText2)-2) + "'" GetCurrentTestName = temp End Function21KViews0likes0CommentsRe: JavaFX Tooltip
I was able to find the phantom Tooltip object Here is what I normally see in the Object Browser when testing the JavaFX GUI. The JavaFXObject(“Stage”, “JDMS”) contain the buttons, panes, etc. The problem with Tooltips is that they come and go quickly. The Object Browser will not usually show them. I was lucky enough to see a flicker in the Object Browser. The flicker was the appearance and disappearance of this. JavaFXObject("Tooltip", "") This flicker seemed to occur directly under the Process(“java”) and not within the branch that contains the buttons, panels, panes, etc. So, I went looking there. I wrote a script to look for the creation of the tooltip while I moved the mouse around on the tested application. Initially, I just looked for a of Sys.Process(“java”) child that contained “tooltip” in the full name. Once, I captured that object I was able to determine the exact full name that I sought to find. There was a trick in that as well. By looking at the Java code for javafx.scene.control.Tooltip, I was able to identify the getText() method for the class (because I couldn’t see the object in the object browser I was unable to see which methods of the object that TestComplete would support). Anyway, the getText() method returned the displayed text, not default text associated with the tooltip field for the button (over which the mouse hover occurs). Here is the script. Sub FindTooltipObject dim Timer1 dim i dim iChildren dim tooltipObj dim tooltipObjFullName dim bFlag bFlag = false 'tooltipObj full name = Sys.Process("java").JavaFXObject("Tooltip", "") 'build strings with Ascii character for quotes tooltipObjFullName = "Sys.Process(" + chr(34) + "java" + chr(34) + ").JavaFXObject(" + chr(34) + _ "Tooltip" + chr(34) + ", " + chr(34) + chr(34) + ")" Timer1 = Time Set javaObj = Sys.Process("java") javaObj.Refresh 'Run do loop and look for conditions that indicate a tooltip is present 'normally Sys.Process("java") will have 11 children -- 'When a tooltip appears, it bumps the total to twelve -- look for the tooltipObj only when ' the javaObj has greater than 11 children 'looking for the tooltip by object when it doesn't occur will slow code execution and 'possibly allow the tooltip to disappear. do 'remember to force refresh to have the javaObj current and containing the tooltip 'object in a child javaObj.Refresh if cint(javaObj.ChildCount) > 11 then for i = 0 to javaObj.ChildCount - 1 'Log.Message javaObj.Child(i).FullName 'comparison by full name without InStr function should be faster if tooltipObjFullName = javaObj.Child(i).FullName then 'if InStr(javaObj.Child(i).FullName, "Tooltip") <> 0 then set tooltipObj = javaObj.Child(i) log.Picture tooltipObj, "Captured tooltip image." 'Log.Message "Tooltip JavaFXObject full name: " + tooltipObj.FullName 'check javafx code for javafx.scene.control.Tooltip for available methods 'because the TestComplete doesn't map this object and finding it and its methods in the object browser will 'be extremely difficult - still getText method works. log.Checkpoint "Displayed tooltip text: " + tooltipObj.GetText() bFlag = true exit do end if Next else 'log.message "nothing to report" end if Loop Until ((Time - Timer1)*20000) > 2 if Not(bFlag) then log.Warning "Fail. No tooltip displayed." end if End sub1.5KViews0likes0CommentsJavaFX Tooltip
I am trying to get TesComplete 10.30 to confirm that a tooltip came up on screen in a JavaFX GUI. The underlying JavaFX code checks a configuration file to determine the correct text to display for the tooltip. Thus, the text associated for the tooltip field that one can access through the object browser does not match what appears on screen. Alternately, what the GUI displays is not the same as what the tooltip field for the associated object has stored for the tooltip field. Also, I cannot determine how to identify whether the tooltip actually appeared at a given time (outside of manually inspecting the Visualizer). I can get the Visualizer to capture the frame when the tooltip is onscreeen, but the Visualizer will not recognize the tooltip as an object. I've been able to do this in script set button1Obj = Sys.Process("java").JavaFXObject("Stage", "JDMS").JavaFXObject("Scene", "").JavaFXObject("ScrollPane", "").JavaFXObject("provisionTitledPane").JavaFXObject("button1") ‘I then got the ‘tooltip’ field for the button1Obj by looking at the fields of button1Obj set result = aqObject.GetFields(button1Obj, True) for i = 0 to result.Count - 1 set objField = result(i) if objField.Name = "tooltip" then set tooltipField = objField set tooltipVObj = tooltipField.Value set tooltipVObj = tooltipField.Value ‘tooltipVObj has JavaFullClassName: javafx.scene.control.Control$3 set tooltipVVObj = aqObject.GetPropertyValue(tooltipVObj, "Value") ‘tooltipVVObj has JavaFullClassname: javafx.scene.control.Tooltip set tooltipVVTObj = aqObject.GetPropertyValue(tooltipVVObj, "Text") ‘tooltipVVObj has tooltipVVTObj JavaFullClassName: javafx.beans.property.SimpleStringProperty set tooltipText = aqObject.GetPropertyValue(tooltipVVTObj, "Value") ‘tooltipText has JavaFullClassName: java.lang.String log.checkpoint "Tooltip OleValue: " + tooltipTextOleValue ‘the OleValue is the default value that the code overwrites when it generates the tooltip log.checkpoint "Tooltip JavaFullClassName: " + tooltipTextFullClassName exit for end if Next Tooltip OleValue is a default value for the tooltip that the code replaces after looking up the button name in a configuration file. When I try to run the FindChild on any of the objects (except the button1Obj which is a JavaFX object) that I set, I get an error (see attached), if not visisble below. I did not find any children of the button1Obj with the FindChild("JavaFullClassName","*"). Here is an example of the command: set javaClass = tooltipField.FindChild("JavaFullClassName","*") I am at a loss for here. I've looked at other threads, but they were not JavaFX-specific and didn't lead me to where I want to be. I wince at the thought of needing to access the JavaRuntime.JavaClasses because I toyed with that approach already and was not able to access the value that I wanted (because the values weren't easily identifiable in the class).1.6KViews0likes1Comment