I am writing a python script that should automatically download an excel file from a website. Yet, in order to generate the excel file, several drop-down lists need to be selected (eg.: Select continent, then select country, then select city... etc.). This means that I need to select one value from the drop-down menu "A" in order for the drop-down menu "B" to show the available values, once the I have selected a value in the drop-down menu "B" I can continue with drop-down "C", and so on.
The problem is that every time I select one value from one drop-down menu (say, from drop-down menu "A") the website is refreshed in order to show the values available for the subsequent drop-down menu.
So far I have been able to access the website with selenium while selecting only a value from the first drop-down menu (eg. Continent), however I am facing difficulties in dealing with the subsequent drop-down menus. Does anyone have an idea of how I could deal with this?
So far my code looks like:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
driver=webdriver.Firefox()
driver.get("https://daten.ktbl.de/feldarbeit/entry.html#0")
element1=driver.find_element_by_name("hgId")
drp1=Select(element1)
drp1.select_by_visible_text("Bodenbearbeitung")
Many thanks in advance,
best
Chico
Well, found out:
wait for the ajax to load the website after the selection:
driver.implicitly_wait(20)
Related
I have a Google sheet where I’m using a dependent drop down for users to select one option and then select a second option depending on their first choice. I'm doing this using a Filter function on a separate tab as range for the dependent list.
I’m trying to figure out a way to auto select the first option of the dependent dropdown (in other words, to set a default value) when the main dropdown is changed.
I have found scripts for clearing out the second dropdown, but not to select one of the available options. I'm a novice when it comes to writing code and I can’t find an answer on the internet.
Any advice would be greatly appreciated!
I’m brand new to using selenium ide.
I’ve gotten all other parts of my coding to work.
But I’m currently having a problem with getting it to choose an option in a drop down menu.
I have the div class name for the drop down and the for the option I’d like to select but nothing I seem to try will work.
I had the same problem and solve it using this algorithm:
- click on the drop-down list
- wait until list appears
- click on list element
or another one:
- click on the drop-down list
- wait until list appears
- send keys ${ARROW_DOWN} to select element of the list
- send keys ${KEY_ENTER}
In my application, I have an option to open the popup menu(by clicking in a specific column of table) & then the function is called using click on any of the menu items
I added a record1, which will be appeared in table with other x,y,z records. SO now I have 4 rows in table.
I want to open popup menu of the record1(which is just created by my test) How can I do that?
All of the work in my app is done using divs. I am finding elements through XPaths but in this scenario I am not able to do the needful.
I want to simulate the user clicking on a text field, using the dropdown and selecting an item.
I can get them on the field and the dropdown working with:
click //input[#id='select_students']
keyPress //input[#id='select_student'] \40
but I can't seem to get 'picking' an item in the dropdown.
I've tried using keyPress with Keys.ENTER as the value but I get forced to put in a Target (selenium IDE in firefox this is) and I don't know what to use as the target.
I could use something that press Enter regardless regardless of target if it's available.
Below logic might be useful for you.
click css=select[id="select_students"]
select css=select[id="select_students"] label=student10
click css=option[value="student10"]
I'm working on an InfoPath 2007 form. I have two drop-down lists and i need the second to be populated with items bases on the value chosen in the first list. I use c# to populate the drop-dpwn lists from external sources. I've tried to use the OnChange event to make all this, but the second list is still empty.
If anyone knows, please tell me.
You can filter the entries for the second drop-down list based on your first list (but only if the entries are based on a data source, not manually entered).
Bring up the properties window for
your second drop-down list.
Select your data source.
Click on the button to the right of the Entries text box.
Select the repeating node you wish to use for the basis of your list entry.
Click the Filter Data button. From here you can enter a filter to limit the entries displayed based on the value of your first drop-down list.
Your question was a bit ambiguous. You may be trying to populate a secondary data source based off of your first drop-down list. This should work fine with an OnChange event. Can you post the code you are using to do this?
Some additional tips that may help:
The change event will not fire until focus moves off of the list box. So, for the second drop down to populate, you will need to set the first drop-down then hit tab or click elsewhere in the form.
I don't know the size or nature of the data source you are using for the second drop-down list, but you may consider downloading the entire data source and filter it using the method I described above. This may be a better solution as you won't need to make a database query between entering the first list box and the second one.