How to assign a string and a string in the vue template? - vue.js

How to assign a string and a string in the vue template?
<q-table
:title=`Lista de ${this.$route.params.tipo}`
/>
error Parsing error: Line 1: Unterminated template

It`s work
:title=' ` Lista de ${$route.params.tipo} ` '

You forgot to add quotes around the template interpolation.
:title="`Lista de ${$route.params.tipo}`"

You do not use this in templates. Actually, everything in the template gets a this automatically.
:title=`Lista de ${\$route.params.tipo}`
Or in simple form, without template string:
:title='$route.params.tipo'

Related

FilePond for Vue / Nuxt : Server property set dynamically?

Little question:
<file-pond
name="customImage"
ref="pond"
label-idle="Déposez votre image ici"
:allow-multiple="false"
accepted-file-types="image/jpeg, image/png"
server="http://localhost:3000'"
:files="custom.customImage"
#init="handleFilePondInit"
/>
Is it possible to dynamically set the server value ?
For example :
v-server="apiUrl+'/api/v1/upload'"
Try this one
:server="`${apiUrl}/api/v1/upload`"
I'm using :server but it can be written as v-bind:server and ES6 Template literals for some better looking interpolation.

Getting attribute's content with xPath

I want to get the attribute's content with this xPath command
"//*[#id="navbarleft"]/div[1]/ul[3]/li[2]/#class"
but it seems like it return the object attribute #class rather than it's content:
Use string function. add your xpath in string function
string(//*[#id='navbarleft']/div[1]/ul[3]/li[2]/#class)

Vuejs, How can I resolve expressions within a string got as a prop?

I'm sorry if this is already solved but I'm not able to find it so I gonna try to be quick.
Imagine one of the props received by my component has the following value:
myAnnoyingProp: "Position of {{$data.name}} {{maritalStatus?\'married\':\'free\'}}"
I tried the following two options but I've got the same result for both:
<label v-html="element.label"></label>
<label>
{{element.label}}
</label>
Expected result:
Position of TheNameSetted free
Obtained result:
Position of {{$data.name}} {{maritalStatus?\'married\':\'free\'}}
PD: I'm using Vue 2.4.2
You could move the login inside your component by making use of 2 props, for example name, which is a String, and maritalStatus, which is either a String or Boolean depending on your needs (the example assumes a Boolean for maritalStatus). Then inside your component construct the message you want to display:
<label>
Position of {{element.name}} <span v-if="maritalStatus">Free</span><span v-else>Married</span>
</label>
You could also use string literals:
myAnnoyingProp: `Position of ${name} ${maritalStatus}`

getText() method returns empty string

This is the HTML of the web page:
<td class=" gridCell wrapText " style="height:27px;" headers="a15" data-post="" title="">
<div class="oflowDivM ">
<span>
<script src="webwb/pzpega_control_text_12877380907.js!!.js" type="text/javascript"/>
<span class="leftJustifyStyle" data-ctl="Text">30,980,030.0000</span>
</span>
</div>
My intention is to extract the value 30,980,030.0000
I am using the following code:
driver.findElement(By.xpath("//td/div/span/span")).getText();
However, the getText() returns an empty string. The xpath is correct as I do not get NoSuchElementException. Could you please help in identifying my mistake here?
Can you please try below and see if value is printed or not:
driver.findElement(By.xpath("//td/div/span/span")).getAttribute("innerText");
If it still happens, can you try to have few seconds of wait and then try yo find element and get the text.
I probably think your element is hidden so getText() returns blank. The comment from #JeffC should fix your problem. Otherwise, try code below:
Thread.sleep(5000);
string text = driver.findElement(By.cssSelector("td > div span.leftJustifyStyle")).getAttribute("innerText");
or find only span which contains string that is longer than 2 characters
Thread.sleep(5000);
string text = driver.findElement(By.xpath("//td/div/span/span[string-length(normalize-space(text())) > 2]")).getAttribute("innerText");
Try this:
String details = "";
Thread.sleep(3000);
details = driver.findElement(By.xpath("//td/div//span")).getAttribute("value");
String amount = driver.findElement(By.xpath(".//*td[#class='gridCell wrapText']//div[#class='oflowDivM']//span//span[#class='leftJustifyStyle']")).getText();
This should work - just make sure class names are correct as in HTML...
From what I found out getText() sometimes returns empty string (if the element is hidden for example. I'm not sure if is or not the only case and neither about the cause).
Anyway what worked for me was getAttribute("textContent").
So how about something like :
driver.findElement(By.xpath("//td/div/span/span")).getAttribute("textContent");
?

Concordion: How get the parameter value inside #TEXT

I am using Concordion to test some java components.
I will write something like
<pre concordion:execute="someFunction(#TEXT, #a)">
{
id:123,
name:<span concordion:echo="#b"/>
}
</pre>
I want to value of #b is calculated and substituted dynamically.
But instead of value #b in someFunction comes an empty string.
Similarly, if use
name:<span concordion:execute="getBValue()"/>
If someone has done something like this, could you please help.
Thanks.
I think Concordion was not design for the purpose of this use case. It is not a template engine. You can transfer the text elements of your specification as input into your automated tests. Additionally, you can use the values inside your specifications as reference to compare the actual outputs of the system under test.
When you want to transfer the result of some method getBValue() into another method someFunction() you have probably several option:
What about calling getBValue() inside your someFunction()?
Or you could transfer the result of getBValue() into a variable and call some Function with this variable:
<pre concordion:execute="someFunction(#TEXT, #a, #b)">
{
id:123,
name:placeholder-for-value-b
}
</pre>
Then inside of someFunction() you could replace the placeholder:
public void someFunction(String text, String aValue, String bValue) {
text.replace("placeholder-for-value-b", bValue);
//continue logic of someFunction
}
you could use the execute command to initialize the variable #name:
<span concordion:execute="#name=getBValue()"/>
followed by the echo command:
name: <span concordion:echo="name" />
or have you tried to call your method directly within the echo command?
name: <span concordion:echo="getBValue()" />
Could your problem be related with the html structure?
When you are using nested elements such as
<pre concordion:execute=...> <span concordion:assert-equals=...>...</span> <span concordion:set=...>...</span> </pre>
Concordion uses the following execution order:
all "standard" commands such as set, echo, etc.
the execute command
assert commands such as assert-equals
This is the way Concordion handles unusual sentence structures.
What about putting the execute-command inside a dedicated span-tag?
<pre> <span concordion:execute=...>...</span> <span concordion:echo=...></span> </pre>