Getting a vaule in a link for later usage in Selenium - selenium

I have a link on my webpage which I need to get the value from and save in for later usage (constructing a direct URL).
The html-link I want to obtain the value from look like this:
<a ng-bind="saving.customerContractName || (saving| savingscontract:$parent.$parent.cmsData) " ng-attr-target="{{(saving.type === 'ASK') ? '_blank' : undefined}}" ng-href="/lpn/mo/Logon.action?avtalenummer=176742" class="ng-binding" target="" href="/lpn/mo/Logon.action?avtalenummer=176742">Fondskonto Link (176742)</a>
The value I need to obtain is 176742.
Any tips on how to extract this value? And further use it in a direct URL call (something) like this:
String url2 = "https://www2-t.storebrand.no/ppjs/#/savings/index/THE_VALUE_HERE";
driver.get(url2);

this might work.
txt = driver.find_element_by_partial_link_text("Fondskonto Link").get_attribute("href").split("=")[1]
url = "https://www2-t.storebrand.no/ppjs/#/savings/index/%s" % txt
driver.get(url)

Related

How to send a variable to a text file that calling to karate feature file...?

Step 01#: I am calling 'Request Date' from json file and saving as "RequestDate"
Background:
json req = read('classpath:XXX/XXX/API/02_Dataset/DataSet.json')
* def RequestDate = get req.GameEnq.RequestDate
Step 02#: I am also calling 'GameDetailsRequest' from json file which has the field called "RequestDate", I would like pass "RequestDate" into "GameDetailsRequest".
Scenario: GameEnq
Given request
"""
GameDetailsRequest
"""
* def GameDetailsRequest = read('classpath:XXX/XXX/API/02_Dataset/ServiceRequestData_GameEnq');
Note: I can able to print the "RequestDate" value correctly ,however i don't know how to call into "GameDetailsRequest"... Please assist me. Your suggestion highly appreciated
Kind Regards
Sudheer Bonam
I think you need to try replace for a text place holder replacement
Add a placeholder <PLACEHOLDER_NAME> in your text data in GameDetailsRequest where you want to insert RequestDate
eg:
* string GameDetailsRequest = "Game release data : <RequestDate>"
* replace GameDetailsRequest.RequestDate = "12-12-2020"
Now GameDetailsRequest will be "Game release data : 12-12-2020"
refer: karate doc for replace

Alfresco : How to search for a specific files types?

I am working to search all PNG files(i.e. all files which has file name extension ".png") in alfresco.
I am using the followingcode, but it does not return any result:
var docs = search.luceneSearch("#cm\\:content.fileType:\"*.png\"");
for (var i=0; i<docs.length; i++)
{
//TO print the name of files--> "Name: " + docs[i].name ;
}
I am not sure if content.fileType is the right way to code to search for file types. Any suggestion please ?
You should go with the content.mimetype query, for example: #\{http\://www.alfresco.org/model/content/1.0\}content.mimetype:text/plain
https://community.alfresco.com/docs/DOC-4673-search#jive_content_id_Finding_nodes_by_content_mimetype
If I use this statement, it helps to find only PNG images:
var docs = search.luceneSearch("#cm\\:name:\"png\"");
If your really want to search for PNG files you should follow Lista's approach using mimetype but with correct syntax
var docs = search.luceneSearch("#cm\\:content.mimetype:\"image/png\"");
searching for name part "PNG" ("#cm\:name:\"png\"") would find any document having a token "PNG" in it's name like png.name.pdf or any_png.doc since document name is stored tokenized in the index

VB.Net Convert text to WWW form

I want to convert text into the WWW form.
E.g: # should be %40, % should be %25 etc...
There's fine encoder here, but i want to do it in VB.Net.
I need this for httpwebrequest, i think it has something to do with x-www-form-urlencoded.
You can use the Uri.EscapeDataString() method for that:
Dim OriginalURL As String = "http://www.example.com/some file with spaces.php?q1=plus+&q2=at#&q3=svenska språkets 'ö'"
Dim EncodedURL As String = Uri.EscapeDataString(OriginalURL)
Online test: https://ideone.com/h5fqm1
And if you want to just escape parts of the URL but still keep valid components such as : / = ? & (etc.) you'd use Uri.EscapeUriString().

Typo3 GP variables in TSSETUP

I use typo3 7.6.10
I learn how get a url variable and store it in other variable for fluid in TSSETUP:
lib.pippomio = TEXT
lib.pippomio.data = GP:cat
example url: index.php?id=10&cat=pino
I print the variable in my template:
<f:cObject typoscriptObjectPath="lib.pippomio" />
Ok it works.
Now i need to print the variable in input by Search Indexed Engine:
<input class="tx-indexedsearch-searchbox-sword" id="tx-indexedsearch-searchbox-sword" type="text" name="tx_indexedsearch_pi2[search][sword]" value="progetto">
How can i store in lib.pippomio the POST Variable "tx_indexedsearch_pi2[search][sword]" ???
I tried
lib.pippomio.data = GP:tx_indexedsearch_pi2[search][sword]
But it doesn't works.
I want to print the word searched in an other place.
You can use a pipe "|" to get it
lib.pippomio.data = GP:tx_indexedsearch_pi2|search|sword
TYPOSCRIPT Reference => getText

How to add data-attributes to a Bootstrap Treeview?

I am using bootstrap-treeview 1.2.0 (from Jon Miles).
My goal is to add custom data-attributes to my list items' markup, e.g.
<li class="list-group-item node-tree" data-id="100" data-type="user" ...>
I tried to follow these instructions see here and here is part of my JSON:
[{"text":"Root","icon":null,"data-id":1,"data-type":"branch","nodes":[{"text":"Steve","icon":null,"data-id":17, "data-type":"user","nodes":...
To me the JSON looks good. But none of my data-attributes gets rendered in the markup.
Any ideas?
Sorry, I see it's too late. I searched about this and couldn't find anything. But you can
change bootstrap-treeview.js file a bit. There is some attribute set code in buildTree function. It's looking like this:
Tree.prototype.buildTree = function (nodes, level) {
if (!nodes) return;
level += 1;
var _this = this;
$.each(nodes, function addNodes(id, node) {
var treeItem = $(_this.template.item)
.addClass('node-' + _this.elementId)
.addClass(node.state.checked ? 'node-checked' : '')
.addClass(node.state.disabled ? 'node-disabled': '')
.addClass(node.state.selected ? 'node-selected' : '')
.addClass(node.searchResult ? 'search-result' : '')
.attr('data-nodeid', node.nodeId)
.attr('style', _this.buildStyleOverride(node));
......................SOME CODES ........SOME CODES..........................}
You can add :
.attr('data-type', node.dataType)
.attr('data-id', node.dataId)
And then change the object(json) like this:
[{"text":"Root","icon":null,"dataId":1,"dataType":"branch","nodes":
[{"text":"Steve","icon":null,"dataId":17, "dataType":"user","nodes":...
The link provided simply instructs how to expand the node object with additional properties. There is no correlation between a node's properties and the attributes assigned in HTML.
You might want to do something like this:
var allNodes = $('#tree').treeview('getNodes);
$(allNodes).each(function(index, element) {
$(this.$el[0]).attr('data-attribute-name', this.data-attribute-name);
});