I just need to select a value from “smart search pick-list” (drop down list) from a web page using webdriver sampler in Jmeter. I already tried using one of it’s pick-list value’s xpath & id and it doesn’t work.
xpath value for "smart search pick-list" field is
.//*[#id='j_id0:frm:searchDiagnosisId']
xpath value for "smart search pick-list" field's one of the value is
.//*[#id='ui-id-21']
If I use sendKeys method, input value just appearing in the text box and not selecting values below. And also remaining script are not executed to fill remaining fields in the webpage. Can you give a solution to select a value from “smart search pick-list”.
Thanks in advance
People mostly use Select class in order to interact with the "dropdown lists", the relevant WebDriver Sampler code will look somehow like:
var select = new org.openqa.selenium.support.ui.Select(WDS.browser.findElement(org.openqa.selenium.By.xpath(".//*[#id='j_id0:frm:searchDiagnosisId']")))
select.selectByValue("....")
See The WebDriver Sampler: Your Top 10 Questions Answered article for more WebDriver sampler tips and tricks
Related
I am new to automated testing with Selenium Web Driver. I am not able to figure it how to test drop down lists of the location type without using the select command. I have div tag.
I was trying to send keys but did not work.
I am working on this website: https://freightpower.schneider.com (>>get a quote>>less than truckload) You may then need to register but it is very quick.
driver.find_elements(by=By.XPATH, value = '//div[#class="dropdownstyle__StyledValueContainer-sc-13n3p0k-2 dIpAqS"]')[0].click()
Then I need to choose one of the options but could not do it. Any help would be appreciated ! I know how I can choose if I could have select tag but now I do not have it and really do not know what to do although checking many related questions.
In my project, I am using selenium automated test. There is an selection box that includes hospital names and user choose hospitals. Maybe you can use find_element_by_id and find_elements_by_tag_name together like this:
try:
el = driver.find_element_by_id('hospital_name')
for option in el.find_elements_by_tag_name('option'):
if option.text == 'Mount Sinai West':
time.sleep(5)
logging.info("Hospital name was added")
option.click()
break
except Exception as e:
logging.exception(e)
raise e
I am trying to make a free open source script to buy shoes, exactly in this page: https://www.zalando.es/nike-sportswear-nike-waffle-one-zapatillas-summit-whitewhite-black-orange-ni112o0jj-a11.html .
I can get elements and click them as usual with driver module
driver.findElement(By.id('uc-btn-accept-banner')).click();
Error happens when I try to pick a foot size, first opening the size selector with
driver.findElement(By.id('picker-trigger')).click(); //THIS ONE WORKS.
driver.findElement(By.xpath('/html/body/div[7]/div/div[3]/div/form/div/div[1]/div/label/span')).click(); // THIS ONE DOESN'T.
I tried clicking some elements by xpath on the site and all of them are working but the foot size.
Can someone help me picking the foot size? I don't mind if it uses other method.
You are using a wrong selector there.
After opening the drop down menu you can select any size by locator like this:
//input[#name="size-picker"]/..//span[text()="39"]
It will be like this:
driver.findElement(By.id('picker-trigger')).click();
driver.findElement(By.xpath('//input[#name="size-picker"]/..//span[text()="39"]')).click();
Just update the value of desired size in the XPath expression
It it a drop down: (But we can not use Select class from Selenium since the drop down is not built using Select option tag)
Click on a drop down using this xpath :
//span[text()='Elige una talla']/..
and click like this :
driver.findElement(By.xpath("//span[text()='Elige una talla']/..")).click();
Now you would see a list of foot size :
Select them with the below xpath :
//form[#name='size-picker-form']/descendant::label[contains(#for, 'size-picker')][3]
This will select 3rd item from the shown list. You have to change [3] to other number incase you would like to select different size.
driver.findElement(By.xpath("//form[#name='size-picker-form']/descendant::label[contains(#for, 'size-picker')][3]")).click();
This should select 40 size
With a standard select2 dropdown box, populated with a list of names from a database call, is there a way to search on hidden items within the search area?
Example:
Select2 box shows to end user "Charlie Watts" but actually the options value holds "Charlie Watts (22)". I want the use to be able to search for 22, but not show it by default to the end user.
TIA
Yep, you can achieve that using the formatResult and/or formatSelection methods. There's a great example of using them in the Select2 Docs: Templating.
In your format function, filter out the " (22)" part of your value and return everything before it.
On a UX note, it could be strange to see matches appear that don't give any indication as to why they match. If that doesn't matter for your use-case, carry on.
I am using ASP.Net MVC 2.0 with C#.
I have a html dropdown control on my page which may contain items with longer text. The page design does not allow me to increase the drop down width so that I can display entire text for each item. To overcome this, I am trying to display a title on mouse over of each item so that use can see the item text. This is achievable using javasctipt and I am happy with the solution. But what if the client has disabled javascript on his browser? Is there any way we can display title for each drop down item without depending on javascript? May be using the "title" attrbute of option or something simillar? I am targeting my code to work for IE8 clients.
Following is my current implementation. I have called a javascript function on mousemove. This loops through drop down options and assigns the selected value to the title attribute of selected option.
<%: Html.DropDownListFor(model => model.SelectedTeamId, new SelectList((IEnumerable)""), "Please Select", new { #class = "wid140", id = "QueryTeam", onmousemove ="ShowSelectedText(this);"})%>
I'm trying to create an auto complete field (using the script.aculo.us plugin) in a form for a category select, but I want the auto complete list to display a number next to each category (the number of other things in the same category). This is similar to the Tags field on stack overflow.
Right now I can display the number I want, but when I select any field the extra number gets dumped into the text field with the category. Currently I'm simply appending the number to each item on the array before I display it. How can I make it so when you select something from the list the number (enclosed in parentheses) does not get put into the text field. Thank you.
I finally solved my problem, I just needed to figure out what some of the plugin's options were. It turns out there is an option for the auto_complete_field helper called :select. The value you provide to this tells the JavaScript which part of the <li> element (the HTML tags the results are displayed in) to return to the text box.
The solution was a simple matter of enclosing the name of the category in a span with a special class and leaving the number part I didn't want outside of this class. This was easy since I was already using my own partial to display the results.