selecting different options from two different drop down menu in Selenium - selenium

How can I select different options from different drop down menus?
after selecting an option from second menu, first drop down menu gets the default value which is first option.
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[5]/div[2]/div/div[2]/div/div[1]/div[2]/div/form/div/div[1]/div/select/option[2]").click()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[5]/div[2]/div/div[2]/div/div[1]/div[2]/div/form/div/div[3]/div/select/option[2]").click()

Try this
import org.openqa.selenium.support.ui.Select;
new Select(driver.findElement(By.xpath("//html/body/div[1]/div[1]/div[5]/div[2]/div/div[2]/div/div[1]/div[2]/div/form/div/div[3]/div"))).selectByIndex(2);
new Select(driver.findElement(By.xpath("//html/body/div[1]/div[1]/div[5]/div[2]/div/div[2]/div/div[1]/div[2]/div/form/div/div[3]/div"))).selectByIndex(2);

Related

Cannot select item from Drop down selenium WITHOUT select

I am new to Python and trying to figure out how to call an item from the drop down list. I managed to make it visible with this code.
price_point = driver.find_elements_by_class_name("chosen-single")
price_point[0].click()
I cannot use Select.
The list is open and visible now But I am not able to click the items inside the list. Any ideas?
Your help is much appreciate!
Access the list item directly and click on it. Here is the sample
driver.find_element_by_xpath("//select[#class='chosen-single']//option[normalize-space(.)='here goes your list item text']").click()
if you have more than one list boxes with class "chosen-single" then use the below to select the item from first list box.
driver.find_element_by_xpath("(//select[#class='chosen-single'])[1]//option[normalize-space(.)='here goes your list item text']").click()

Is there an Python-PyQt5 function for multiselecting from a list using QCombobox?

I am trying to build a GUI with a dropdown for multi-select in python, PyQT5 but, the display is only showing single item instead of a dropdown. Is there a way to include the options as a drop down ?
QlistWidget has the setSelectionMode: QListWidget and Multiple Selection
But the combobox does not seem to have it. And I don't remember seeing a combobox with multi selection on.
No, you can't select multiple item from a QComboBox instance. It can be used to select only one item at once. If you want to have multiple selection in your widget have to use a QListView/Widget.

Not able to click on drop down menu

I have 4 drop down menu in my application and when we click on any drop down then selection list appears. So I am able to click on first drop down and can select any value from list.
My Issue : I am not able to click on 2nd drop down to choose value.
Xpaths used for 1st and 2nd drop down-
1. ProcessName_xpath=//span[contains (text(),'Process Name :')]
2. ProcessStatus_xpath=//span[contains (text(),'Status :')]
if I remove 1st click step from my test cases then status xpath works fine.
When used both steps, 2nd step is failing. Why?
Error:
Unable to locate element
you can use explicit wait until the element is present. I am not sure which programming language you are using, so following code is in python
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//span[contains (text(),'Status :')]")))

Tosca: How to scan Dropdown textbox which disapper upon opening xScan

I have a problem in scanning a drop-down menu which disappears upon opening the xScan. I need to get the module id of the dropdown menu to verify some test steps.
Do you have any solution with this if it is not really possible to get the module id of the dropdown menu?
Open developer tools in your browser of choice (F12), navigate to the console and input the following code:
var fulldoc='';
var scrollX=0;
var scrollY=0;
document.addEventListener("keydown",function(event){
if(event.key=='q' && event.altKey){
fulldoc=document.body.outerHTML;
scrollY=window.pageYOffset;
scrollX=window.pageXOffset;
}
if(event.key=='w' && event.altKey){
document.body.outerHTML=fulldoc;
document.body.scrollTo(scrollX,scrollY);
}
});
When the window looks the way you would want to scan, press 'Alt + Q', then press 'Alt + W'.
Now your window will freeze and then you can scan your page.
To steer the objects you need to refresh your browser.
You can resolve the issue with below 2 steps
1 - Add some text in textbox which will populate the dropdown below it .
2 - Use Send Keys Module to scroll down and select the value.
I had a similar issue where we had a popup that only appeared when clicking on a text box. The solution we received from the Tricentis trainer was as follows:
Part One
1. Open your application in Chrome
2. Right click the inspect
3. In the inspector window, on the Elements tab, navigate to your html element where it should be (you can do that by clicking on the element and check that you can see the html in the element)
4. Use the debugger to add a break point there, this should pause it and you should be able to see the elements you need to steer it.
5. Once you found the element, you will need the type of element (e.g. div, span, etc), and the class name
Part two
1. Rescan your module and select any element that matches the criteria of your element selected in Part One #5
2. Identify it by only it's class name property and tag
3. Save and close
4. Edit the element in the module view by changing the class name. This should help you steer it
Note: if the element class name is not unique, you might need to use Explicit name.
Good luck

Populating options for drop down list

I have a list that I will have users enter data into, each user needs to select their own location. First I created a drop down field with all the options. The column can be set to force unique values, but this doesnt check until the end when the user goes to save.
Is there a way to check if the users selection is already entered, immediately when the option is selected? (without having to hit save)
OR
Another option I tried was:
Create a separate list with two columns: name and saved. Call it Location_List
Create a view that displays all where saved = no on Location_list
Populate the options on the mainList from a look up the the Location_List. This works.
Add a workflow action to mainList that updates saved = yes on the Location_List. This part doesn't work. Does sharepoint allow this though?
Is there an easier way to accomplish this?
My second option worked, had simply forgotten to update the workflow setting to "Start automatically when item is created" for it to run accordingly.