Slash didn't find element working with variable(Python) - selenium

/*[contains(text(),\'TextToFind\')]
When we find it through this xpath, Elements was not able to find it,
Once we remove slash its able to find.
It placed automatically, while passing through variables.
Any working solution with python-varible ?

You can use the python format() function to pass variable.
driver.find_element_by_xpath("//*[contains(text(),'{}')]".format(variableTextToFind))

Related

JMeter - get value from href

I am load testing an application that has a link that looks like this:
https://example.com/myapp/table?qid=1434e99d-5b7c-4e74-b64e-c24e9564514d&rsid=5c94ddc7-e2e4-4e69-8547-49572486f4d1
I need to get the dynamic value of the rsid so I can use it later in my script.
So far I have tried using the regex extractor and I am probably doing it wrong.
I have tried things like:
name = myvar
regular expression = rsid=(.*?) # didnt work
regular expression = <a href=".*?rsid=(.*?)"> # didnt work
Template = $1$
I have one extractor set up to get the csrf value and that one works as expected but that is also because the csrf value is in the page source.
The above link is NOT in the page source as far as I can see but it DOES show up when I inspect the link. I dont know if that is obfuscation or something else?
How can I extract the value of the rsid? Is the regular expression extractor the right one to use for this?
Should I be using something else?
Is it just a formula issue?
Thanks in advance.
Try something like:
rsid=[0-9A-Fa-f\-]{36}
the above regular expression should match a GUID-like structure and your rsid seems to be an instance of it.
Demo:
Also be aware of the Boundary Extractor, it's sufficient to specify "left" and "right" boundaries and it will extract everything in-between. In general coming up with "boundaries" is much easier than creating a regular expression, it's more readable and JMeter processes the Boundary Extractors much faster. More information: The Boundary Extractor vs. the Regular Expression Extractor in JMeter

What is the correct way to use multiple variables in a Text element?

I can't seem to find the "correct" way to use multiple variables in a React Native Text element.
I have the users first, and the last name as separate object values and I want to show them in the same Text element.
<Text>{props.user.firstName} {props.user.lastName}</Text>
This works fine, but ESLint doesn't like it. (jsx-one-expression-per-line).
If I put them on separate lines, then I can't figure out where to put the empty space in between first and last name.
<Text>
{props.user.firstName}
{props.user.lastName}
</Text>
There's an empty space after {props.user.firstName}, but ESLint doesn't like that either (no-trailing-spaces).
So I'm asking whether there is a correct way to achieve the result that I want without changing ESLint configuration or creating a separate variable.
You're looking for template literals.
You can nest your variables like so:
<Text>`${props.user.firstName} ${props.user.lastName}`</Text>

workfusion webelement has two variable ad doesnt take anything

Workfusion I am trying to make two variables through web-element. When running individually its great but when running separately it has problems.
Please see the picture for the same. This doesn't get executed.
If your XPath has any variable then try the giving a value like following:
//*[#id="mv-tiles"]/a[${i}]
and you can keep changing value of i through loop. A variable inside another will throw error in Workfusion RPA Express.
The ${} evaluates the whole it's body.
Does the following, without nested ${} execute OK?
${webrange[countertemp]}

how to locate dynamic element using xpath(ends-with function not working)

I have used ends-with function as
(By.xpath("//input[ends-with(#id,'_PHONE$']"));
But it didnot work
The ends-with function is part of XPath 2.0 but browsers generally only support 1.0.
So, if you strictly want to fetch all elements that ends with a specific pattern, you can either fetch all elements that contain that pattern (using the contains() function) and then strictly check the suffix of the id (fetch the attribute value by .getAttribute("id")) using Java's .endsWith() method.
Or
You can use string-length function, substring function and equals to get this XPath:
"//input[substring(#id, string-length(#id) - string-length('_PHONE$1') +1) = '_PHONE$1']"
driver.findElement(By.xpath("//id[contains(text(),'PHONE$')]"));
You can use below XPath as well:-
//input[contains(#id,'PHONE$1')]
Hope it will help you :)
Your id is ending with _PHONE$1 and not _PHONE$. Notice that there is a 1 at the end.
(By.xpath("//input[ends-with(#id,'_PHONE$1']"));
If you still don't want to match that 1 use contains.
By.xpath("//input[contains(#id,'_PHONE$1']"));
Use contains Method
By.xpath("//input[contains(text(), '_PHONE$']");
Or use wait explicit method

Mule variable in MEL as String

i have an expression bellow to read a file from resources :
#[Thread.currentThread().getContextClassLoader().getResourceAsStream('abc.txt')]
it worked fine, but i want to use a variable like this one:
#[Thread.currentThread().getContextClassLoader().getResourceAsStream(flowVars['fileName'])]
it does not work,
how can i make it work like the first one MEL ?
how can i read a file in absolute path "D://input/abc.txt" using MEL ?
Thanks for helps.
resolved
use flowVars.filename instead of flowVars['fileName'] it worked, but i can't get it, i use logger with this MEL #[flowVars['filename']] and it work too but in the second MEL it failed.
1) You are using a different case with the two different approaches. Variable names are case sensitive.
2) Just use a FileInputStream:
#[new FileInputStream("path")]
Or even better maybe to use the File transport/Mule Requester Module.
Try this, Use variable name instead of using keyword "flowVars"
#[Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)]