TestComplete_JavaScripting_how to hide web url path while performing any operation for any object in script - testcomplete

I'm new to use Testcomplete , i'm using javascripts to automate my code, below are sample script ( converted one recorded first then converted into jscript) and in this scripts what i observe that TestComplete identified and captured the object element by using complete web url path not on only object specific .
efunction Test_Login {var UserName, Password, TestEnv;UserName = "XYZ";Pwd = "XYZXYZ";TestEnv = "https://test.Env.com/";Browsers.Item(btChrome).Run("TestEnv",1);Aliases.browser.pageTestenvCom.formFrmlogincomponent.textboxUsername.SetText("UserName");Aliases.browser.pageTestenvCom.formFrmlogincomponent.passwordboxPassword.SetText("Pwd");Aliases.browser.pageTestenvCom.formFrmlogincomponent.buttonLogin.ClickButton();}e
what i means lets see below example of login page
thank you

Whenever we record any Test case in Test-Complete, it stores all the object in the Naming Repository and then access the same.
This helps test-complete in easily recognisation of object and can improve the speed of test-case, in case there are multiple objects visible on screen
You can go through following link for more info on Name Mapping.
https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/overview.html

Related

Set parameter value programatically while generating QuickSight embedded report URL

I am working on the QuickSight embedded report url generation. I am trying to set the parameter default value programatically using below JAVA code.It is not working.
GetDashboardEmbedUrlRequest req = new GetDashboardEmbedUrlRequest()
.withAwsAccountId(awsAccountId)
.withDashboardId(reportInput.getDashboadId())
.withUserArn(userArn)
.withIdentityType(EmbeddingIdentityType.QUICKSIGHT)
.withSessionLifetimeInMinutes(sessionTimeout);
req.putCustomQueryParameter("CampaignName", "ABC");
req.putCustomQueryParameter("reportDev", "Program");
// get the dashboard URL
String embedUrl = quickSightClient.getDashboardEmbedUrl(req).getEmbedUrl();
LOGGER.info("URL:{}",embedUrl);
In the above code, "CampaingName" is multivalues parameter attached to the dropdown control. It's default value is set to "[All]" while building a report. Parameter "reportDev" is single value parameter with no default value and no control or any thing attached to it. Dummy parameter I introduced for testing.
After running the code, when I copy the url printed in console by logger and run it in the browser, report opens properly but with "CampaignName" and "reportDev" both set as "ALL".
Sample generated ulr is as below
https://xx-xxxx-x.quicksight.aws.amazon.com/embed/xxxxxxxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxxxxxx?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&identityprovider=quicksight&isauthcode=true
Well if I get the dashboard url and pass the parameter in the url to, it worked properly. "CampaignName" is set to "ABC" and "reportDev" set to "Program". According the data in the report also got filtered. Url working corrctly as below.
https://xx-xxxx-1.quicksight.aws.amazon.com/embed/xxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxx#p.reportEnv=Program&p.CampaignName=ABC
Can anybody please tell me what is missing in my code. I tried below variation as well but no luck.
req.putCustomQueryParameter("p.CampaignName", "ABC");
req.putCustomQueryParameter("p.reportDev", "Program");
Have you tried to drop the p. from the parameter name, eg
req.putCustomQueryParameter("CampaignName", "ABC");
req.putCustomQueryParameter("reportDev", "Program");
I know that worked for the javascript sdk.

Apache Geode - Creating region on DUnit Based Test Server/Remote Server with same code from client

I am tryint to reuse the code in following documentation : https://geode.apache.org/docs/guide/11/developing/region_options/dynamic_region_creation.html
The first problem that i met is that
Cache cache = CacheFactory.getAnyInstance();
Region<String,RegionAttributes<?,?>> regionAttributesMetadataRegion = createRegionAttributesMetadataRegion(cache);
should not be executed in constructor. In case it is , the code is executed in client instance , it is failed on not server error.When this fixed i receive
[fatal 2021/02/15 16:38:24.915 EET <ServerConnection on port 40527 Thread 1> tid=81] Serialization filter is rejecting class org.restcomm.cache.geode.CreateRegionFunction
java.lang.Exception:
at org.apache.geode.internal.ObjectInputStreamFilterWrapper.lambda$createSerializationFilter$0(ObjectInputStreamFilterWrapper.java:233)
The problem is that code is getting executed on dunit MemberVM and the required class is actually the part of the package under which the test is getting executed.
So i guess i should somehow register the classes ( or may be jar ) separately to dunit MemberVM. How it can be done?
Another question is: currently the code is checking if the region exists and if not it calls the method. In both cases it also tries to create the clientRegion. The question is whether this is a correct approach?
Region<?,?> cache = instance.getRegion(name);
if(cache==null) {
Execution execution = FunctionService.onServers(instance);
ArrayList argList = new ArrayList();
argList.add(name);
Function function = new CreateRegionFunction();
execution.setArguments(argList).execute(function).getResult();
}
ClientRegionFactory<Object, Object> cf=this.instance.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).addCacheListener(new ExtendedCacheListener());
this.cache = cf.create(name);
BR
Yulian Oifa
The first problem that i met is that
Cache cache = CacheFactory.getAnyInstance();
should not be executed in constructor. In case it is , the code is executed in client instance , it is failed on not server error.When this fixed i receive
Once the Function is registered on server side, you can execute it by ID instead of sending the object across the wire (so you won't need to instantiate the function on the client), in which case you'll also avoid the Serialization filter error. As an example, FunctionService.onServers(instance).execute(CreateRegionFunction.ID).
The problem is that code is getting executed on dunit MemberVM and the required class is actually the part of the package under which the test is getting executed. So i guess i should somehow register the classes ( or may be jar ) separately to dunit MemberVM. How it can be done?
Indeed, for security reasons Geode doesn't allow serializing / deserializing arbitrary classes. Internal Geode distributed tests use the MemberVM and set a special property (serializable-object-filter) to circumvent this problem. Here's an example of how you can achieve that within your own tests.
Another question is: currently the code is checking if the region exists and if not it calls the method. In both cases it also tries to create the clientRegion. The question is whether this is a correct approach?
If the dynamically created region is used by the client application then yes, you should create it, otherwise you won't be able to use it.
As a side note, there's a lot of internal logic implemented by Geode when creating a Region so I wouldn't advice to dynamically create regions on your own. Instead, it would be advisable to use the gfsh create region command directly, or look at how it works internally (see here) and try to re-use that.

How to scrape the data using requests module only in python

I am actually trying to parse a website using the requests module, and extract some text out of it.
Url : https://www.icsi.in/student/Members/MemberSearch.aspx
after hitting the url in the Cp Number text field input : 16803
hit search,
on the bottom you can see some data, I want that data, let's say a name.
I am successfully able to get the data using selenium, but can't able to get it using requests module.
I have tried the requests module giving parameters, sessions, cookies etc.
but nothing worked.
url = "https://www.icsi.in/student/Members/MemberSearch.aspx"
ss = {'dnn$ctr410$MemberSearch$txtCpNumber':'16803',
'__EVENTTARGET':'dnn$ctr410$MemberSearch$btnSearch',
'__VIEWSTATEGENERATOR':'6A295697',
'dnn$ctlHeader$dnnSearch$Search':'SiteRadioButton'}
session = requests.Session()
cookies = session.cookies.get_dict()
for cookie in cookies:
session.cookies.set(cookie['name'], cookie['value'])
response = requests.post(url, data=ss)
print(response)
HTMLTree = html.fromstring(response.content)
name = HTMLTree.xpath('//div[#class="name_head"]//text()')
print(name)
I expect the output of the name of the person.
Anyone out there please help me.
If you don't mind using C# code I would be more than happy to help you otherwise it's a very lengthy process. If you choose that python is the only road you're willing to take then you should try grabbing the encrypted value within C:\User[USERNAME]\Appdata\Local\Google\Chrome\User Data\Default\Cookies You can change the file path accordingly to your OS. You can use SQLite to read and modify the encrypted values.
cookie = Decrypt(Encoding.Default.GetBytes(SQLDatabase1.GetValue(i, "encrypted_value")
if (cookie.Contains(".ASPXANONYMOUS")):
Step1 = cookie + "END"
Step2 = (step1 + ".ASPXANONYMOUS")
The following code above may help you with your journey.

How do I correlate two identically coded variables sent in the response from a Worklight server response string in LoadRunner 12.02?

I am trying to create a load test versus one of our apps that is used on web and mobile. I am trying to access this app from the web. I login to the website. Using this login, I click on the web version of the app. The below response is returned here.
This app is using SiteMinder and Worklight to negotiate with the main site I am coming from.
My question is, how do I correlate a value such as 'SMIDENTITY=' when it is being returned TWICE in the same string?
Here is an example of what is being returned by the server (I have broken up the string so the variables are separated:
Test4.c(225):
Cookie:testcookie=oreo;
SMIDENTITY=Cq16kwJwrJWgBd5zQ8ci0kP8IEZ47kftOxMr1wVsxx+W/7sGS92ZA9zu69GRpolh0PRX97bvfHRya0m1ty1E07qR0HjKKXE8ypRsWPgG4m2w8mlspPUxL8t5Z4RE5/CCJpOxpXHIHeQK4f77gkihKFq8cBQr+Vy9kZGFGMUJH6+EiLNmmJT+XYZcUi7gzV0r+naJypMewtXAYaOcvn8Kqsu2JA5SiNUcJbxxX4dNCHOsC4cf45Jm0H40Efq6nOwN7MDyAE2gXSou4oa9ZlYxlsvWdEVl6CxgnqnqEkBJYVuBsgj/277+F7q9KB4xpct/sY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b4l3mm8;
SITE_ENTRY_JUMPTO=polhome;
scoreboard="";
scoreboardReport="";
WLSESSIONID=0000Xr6ZS67VI4UH-HoycrnVBq1:18lm04lom\r\n
Use the Ordinal (or index) number of the instance of the variable which you need as part of your collection
See training material or online help for correlation functions related to ordinal value
You didn't say what you're actually trying to do. Do you need only use the most recent? only use the first?
You use a web_reg_save_param_ex to capture all Ordinals of a parameter. It puts it into an array.
You can then do what you want with that array.
You can also use a web_reg_save_param_regexp
I coped the code from the official documentation and put your variable name in there to make it easier for you.
web_reg_save_param_ex(
"ParamName=SMIDENTITY",
"LB/IC=SMIDENTITY=",
"RB/IC=;",
"Ordinal=all",
LAST);
web_submit_data("...");
/* Getting individual elements from a parameter array.
Since the parameter created by web_reg_save_param_ex
is called "SMIDENTITY", the number of elements
is saved in parameter "SMIDENTITY_count".
The array elements are parameters "SMIDENTITY_1",
"SMIDENTITY_2", ... "SMIDENTITY_n".
*/
elemCnt = atoi(lr_eval_string("{SMIDENTITY_count}"));
lr_output_message("Number of items found = %d",elemCnt);
for (x=1;x<=elemCnt;x++) {
sprintf(arrayParamName, "{SMIDENTITY_%d}", x);
lr_output_message ("%s: %s",
arrayParamName,
lr_eval_string(arrayParamName));
}

HP UFT API Test - Saving Response/Checkpoint values

Is there a way to capture and store (or write to a file) the values returned in the Response? (Checkpoint values)
Using HP UFT 11.52
Thanks,
Lynn
I figured it out. In UFT API under Standard Activities, there are File function modules including "Write to File". I added the module to the test, set the path and other properties, passed the variable to the file and it worked! Couldn't be easier.
I mentioned this on my other answer , you can also write it programatically if you have dynamic array response please refer below:
https://stackoverflow.com/a/28012383/3972994
After running a test, in the test folder, you can find a Snapshots/LastIteration directory.
In it you can find the return value for each step saved in a txt file.
Pay attention that if you data drive the step, only the last iteration will be saved to file.
However, in the Test's log (Test dir/Log/vtd_user.log) you can find all the iterations persisted
Thanks,
Yossi
You do not need to use the standard activities if you do this
var iResponse = this.Activity.responsebody;
System.IO.File.WriteLines(#"directorypath&FileName);
the above will write the response to the file and rewrite it for every run

Resources