Launch Browser in Incognito/Private Mode
Thought of sharing the code in the community for launching browsers in their incognito modes. The function is parameterized such a way to run for the browsers Internet Explorer, Edge, Chrome and Firefox. Hope it will be useful for more people. function runIncognitoMode(browserName){ //var browserName = "firefox" //iexplore,edge,chrome,firefox if (Sys.WaitBrowser(browserName).Exists){ var browser = Sys.Browser(browserName); Log.Enabled = false // To disable the warning that might occur during closing of the browser browser.Close(); Log.Enabled = true // enabling the logs back } if(browserName=="edge"){ Browsers.Item(btEdge).RunOptions = "-inprivate" Delay(3000) Browsers.Item(btEdge).Run(); }else if (browserName=="iexplore"){ Browsers.Item(btIExplorer).RunOptions = "-private" Delay(3000) Browsers.Item(btIExplorer).Run(); }else if (browserName=="chrome"){ Browsers.Item(btChrome).RunOptions = "-incognito" Delay(3000) Browsers.Item(btChrome).Run(); }else if (browserName=="firefox"){ Browsers.Item(btFirefox).RunOptions = "-private" Delay(3000) Browsers.Item(btFirefox).Run(); } Sys.Browser(browserName).BrowserWindow(0).Maximize() }3.8KViews8likes3CommentsReadyAPI - How to use code in the custom properties of a test step ?
Say we have a test step which actually calls/runs some test case. One of the properties, say ID has a variable value which is set by something else (script, another test step etc.). E.g. like this: ID :${TestCase-GetId#ID}. Can I use code inside the value box/field to alter the value of ID? This will be useful for ad hoc testing or could be used normally in the test. E.g. ID : ${TestCase-GetId#ID}.subString(0, 5). I don't want to create another groovy script for minor changes to property values. I know that we can prepend or append constants to the value easily like this - ID : MyId_${TestCase-GetId#ID}. But, I don't know if we can use code there instead. If we can use code, then are there any limitations (e.g. the code should be 100 characters or less) ? Keywords - script in custom properties editor, code in custom properties editor, alter the value of a custom property, code in the value of a custom property, script in the value of a custom property, code in the custom properties of a test step.Solved1.1KViews0likes2CommentsPassword Variable not passing the password
Trying to pass a secure password through the aqHttpRequest using the encrypted variable type of password. And it seems to pass a generic name in the logs when I try to access it. If I hard code the password it works fine. Trying to pass the password in aqHttpRequest["SetHeader"]("authorization", "Bearer " + Project["variables"]["AccessToken"]); In both the web logs and the test complete logs it shows {RandomNumbers}TestProject2AccessToken. If I useaqHttpRequest["SetHeader"]("authorization", "Bearer " + "ActualPassword"); it will work fine.Solved1.6KViews0likes3CommentsOption to switch logging tabs from bottom to the right
It would be great if there were an option to change logging tabs from the bottom to the right side of the gui. Sometimes I'm monitoring properties and steps in a test, and I'd like to see the script log specifically on the right. This way we have more control over the screen real estate. Currently if you want to view both, you have to sacrifice space for script logs, or observing teststeps, or properties.602Views0likes0CommentsGroovyUtils XMLHolder throwing Xpath syntax error when XML node value contains escaped character.
GroovyUtils throwing error when XML node value contains escaped characters. In my script, I'm accessing a node that contains the description of an error. That node when read by my XMLHolder throws this error: Caused by: java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 9 on line 2 in {\nInvalid part number}: Unexpected token name "part" beyond end of expression It appears that the node I'm reading contains the value "\n", and when the holder tries to read it, it throws the error. How can I read the node, with the escaped value, and not bomb out?3.8KViews0likes12CommentsCustom “On Error Actions” by having a “Raise exception” option in the on error column
Attached as a PDF is my idea in a better format! In the project window there is a drop down under the column of On Error. This field determines what TestComplete does when it encounters an error. The option of this are Continue running, Stop test item, Stop project, or Inherit from project. I would like to add one option to this called Raise exception. This would allow users to do their own error handling by wrapping their entire test function associated with the test item in a try catch statement. One use case for this would be running a test multiple times with different data (ie: Account Number). When an error occurs we would like it to move onto the next account not continue executing with this same account so continue running will not work in this case. If we use stop test item we will not be able to execute the accounts after it. This is why there should be a 5th custom option that will let you handle it yourself. This is how a test case would be structured with multiple data points (ie: account numbers) if this feature existed: def MultipleDataPointTest(): accounts = ReadAccountsNumberDataBase(querry) for account in accounts: try: #Arrange testCaseAccountNumber = int(account[0]) Log.PushLogFolder(Log.CreateFolder("Test data: " + str(testCaseAccountNumber))) #Act TestStep1() TestStep2() TestStep3() #Assert confirmValue = getValue() if(not confirmValue): Log.Error("Test Failed") Log.Error("Test Passed") CloseOpenBrowsers() Log.PopLogFolder() except Exception as e: CloseOpenBrowsers() Log.Warning("The error was: " + str(e)) Log.Warning("Moving on to next account.") Log.PopLogFolder() continue This problem arises because Smart Bears has there own error handling and when there is an error in one of the TestComplete modules it is already handled. See code below for what kind of errors throw exception when test item on continue running: #generic function to call possible functions errors def Testing(): try: #replace with any below to see result Error2() except Exception as e: Log.Warning("The error was: " + str(e)) pass # generic python error # WILL raise exception def Error1(): Log.Message(badvar) Log.Message("Still going") # Click on Object that does not exist # will NOT raise exception def Error2(): Aliases.browser.Click() Log.Message("Still going") # Enter .Keys() on Object that does not exist # will NOT raise exception def Error3(): Aliases.browser.Keys('[Enter]') Log.Message("Still going") # Log.Error(string) # will NOT raise exception def Error4(): Log.Error("Bad thing") Log.Message("Still going") # Purposeful execution raising # WILL raise exception def Error5(): Log.Error("Bad thing") raise Exception Log.Message("Still going")1.5KViews3likes1CommentCompare text property of two objects
Hello, I am having a simple issue trying to compare two text values in keyword test where one value is greater than other. I had used compare property checkpoint, and the comparision is not correct.(you can see it from the printscreen). After that i had tried to do it in script, same with compare property checkpoint and the result was the same as in the keyword test. Also i had tried to do with if then statement:if (raspSr > vkIznos) then Log.message('ok') else log.error('notok') where i had defined my two variables as a String( var raspSr: string; var vkIznos: string), but it doesnt help. I constantlly get the incorrect results for everything mention above. I am sending you the printscreen results, any help will be welcomed.Solved1.7KViews0likes4CommentsServiceV Pro: Default response unexpectedly replacing the scripted one
First thing first: I'm new to the ServiceV product, just got it few days ago. I'm creating a virt api where the following path is being used: /api/aicm/v1/subject/{subject_nr}/mandate/{creditor_id} where subject_nr and creditor_id represent the required TEMPLATE parameters. Beside the main success scenario (GET: -> HTTP 200 OK), where both arguments are made available in the URI, I'm trying to handle the following alternative scenarios in my virt api: a) GET: {subject_nr} is empty -> HTTP 400 Bad Request b) GET: {creditor_id} is empty -> HTTP 400 Bad Request c) GET: both {subject_nr} and {creditor_id} are empty -> HTTP 400 Bad Request The test paths associated with the four scenarios (1 main + 3 alts) are: 1. HTTP 200: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/AB51TST405365330000 2. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/AB51TST405365330000 3. HTTP 400: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/ 4. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/ I use the "Dispatch Strategy: Script" with default response returning HTTP 404 Not Found, and the following validation script to check the path arguments and return the appropriate response: assert log log.info("Executing dispatch script...") assert requestContext def props = requestContext.getProperties() assert props log.info("Request arguments: ${props}") def subNr = props["subject_nr"] def credId = props["creditor_id"] if (subNr.empty || credId.empty) { // return HTTP 400 return "GET 400 Bad Request" } log.info("subject_nr: ${subNr}") log.info("creditor_id: ${credId}") def isSubNrMatching = subNr ==~ /^\d{10}$/ log.info("subject_nr RegEx match is: ${isSubNrMatching}") def isCredIdMatching = credId ==~ /^(ab|AB)(\d{2})([a-zA-Z]{3})(\d{8})(0{4})$/ log.info("creditor_id RegEx match is: ${isCredIdMatching}") def areReqArgsValidated = isSubNrMatching && isCredIdMatching if (!areReqArgsValidated) { // return HTTP 400 return "GET 400 Bad Request" } log.info("Request arguments validated: ${areReqArgsValidated}") // return HTTP 200 return "GET 200 OK" Now, the problem is: Main success scenario and alternative scenario a) work just fine (meaning: in both cases I get the expected response dispatched by the script). With the remaining scenarios b) and c), a response with HTTP status code 404 is dispatched instead of the scripted one (400). This response is apparently not the default 404 response I created andselected in the "Default Response" drop-down list (which features a JSON payload in the body), for its body is empty. Additionally, no log output shows up in the script (or error) log tab, showing clearly thatthe dispatch strategy script is not executed. Any clue about why is this happening? Am I missing something fundamental, due to my lack of product knowledge?Solved6.4KViews0likes16Comments