Can you please advise how to rewrite the below code with contains syntax for Dynamic Name? Please refer the attached screen capture. Thanks a lot.
WDS.browser.findElement(org.openqa.selenium.By.xpath("//li[#id='cascader-menu-9503-0-3']/span")).click();
I fail to see any element having id of cascader-menu-9503-0-3 at your screenshot, if you want to click this "Location" dropdown it's better to stick to its valuesdatasource attribute like:
//div[#valuesdatasource='location']
The general syntax for the contains() function is:
contains('target', 'criteria')
so in your case it would be something like:
//li[contains(#id, '9503')]
or
//li[contains(#id, 'cascader-menu')]
References:
XPath Tutorial
XPath Language Specification
Using the XPath Extractor in JMeter
Related
Thank you for your prompt responses. I have tried the below codes but looks like not picking up the values because there's 3 level of variables. Can you please advise? Thanks.
1st level: xpath=(//input[#type='text'])[7]
2nd level
it doesn't work: //li[contains(#id, 'cascader-menu')]/span
or
it doesn't work: //li[contains(#id,'cascader-menu')]/span1
I don't think anyone is capable of coming up with a proper unique locator by looking at the screenshot without having access to full DOM or application
From what I can see so far you need the following element:
//input[#placeholder='Select...']
However it may or may not work depending on:
whether there is another input element matching this query, if there are more than one - the action goes to the first match
it is visible
it can be interacted with (i.e. not covered by a modal window or not disabled)
phase of the moon
You can test your expressions using your browser developer tools and given you will get the match - Selenium will also be able to find the element and hopefully work with it.
If you going to continue repeatedly ignoring my suggestions of getting familiarized with DOM and XPath concepts I can only suggest recording the scenario using Selenium IDE or JMeter Chrome Extension and hope that it could be replayed without modifications.
Is there a way to retrieve complete xpath of an element handle using puppeteer ?
Note - I'm NOT asking about page.$x('specific_x_path') method. Instead I'm asking about the opposite of it.
i.e. I have identified the element handle using classes and other data set and would like to use puppeteer to retrieve it's complete XPATH in the DOM tree.
Thanks in advance.
I want to click on a button on a website. Is there a code which can allow me to click on the element by using the TEXT field? I can neither use the resource id field nor name as they are empty. I tried to click on the element using the xpath but that did not work.
this is example using Java, but i believe that it is pretty easy to migrate it to a Python.
You need to use AndroidUiAutomator:
androidDriver.findElementByAndroidUIAutomator("new UiSelector().text(\"your_text\")").click();
Is it possible to make a script that compute a "ctrl F"?
I have a list of societies. I want to get (for exemple) the values of those societies.
For each society of my list my script:
- go on google
- type the name of the society
- click on search
- go to the first url
And now, I am on the good website.
I want to go through all the pages and look for the word "value" (= do a ctrl F) to collect a list of word behind...
The idea is to get the list of values of each society...
You can achieve what you want with an xpath selector.
In this SO topic you can see how you can use xpath selectors with beautifulsoup.
The xpath expression to search for the text "value" would be something like:
//*[text()="value"]
If you need to improve this expression, refer to this great guide about xpath expressions.
What is the name of function in Citrix protocol of LoadRunner to capture the text with the help of regular expression?
Please give a example.
Because of the way Citrix protocol works you currently have no way to "search" for text with regexp or otherwise. Your only options are the ctx_get_text steps, each using a different method to try and retrieve the text. If you think that something like regexp search is a useful feature please suggest it as an ER.