How to select item from dropdown list using Helium?

37 views Asked by At

I've recently begun writing some basic Python code using the Helium library. Here's what I've done so far:

from helium import * 
start_chrome('https://eureka.mf.gov.pl/informacje/podglad/573501')
click('Eksportuj')

After clicking the 'Eksportuj' button, a new floating window appears, which includes the following elements:

A dropdown list with various values, and I need to select the 'txt' option. Another 'Eksportuj' button. I'm wondering how I can modify my script to handle this new window and perform the required actions (i.e. exporting the content to txt file)?

1

There are 1 answers

2
ZH Bani On

To select an item from a dropdown list using Helium, you can use the select() function. In your case, it looks like you want to click on the "Eksportuj" button, which might not be related to selecting an item from a dropdown. However, if you have a dropdown on the page and you want to select an item from it, here's how you can do it:

Assuming you have an HTML dropdown like this:

<select id="myDropdown">
  <option value="option1">Option 1</option>
  <option value="option2">Option 2</option>
  <!-- Add more options as needed -->
</select>

You can use Helium to select an item from this dropdown:

from helium import *
start_chrome('https://eureka.mf.gov.pl/informacje/podglad/573501')
# Assuming 'Eksportuj' is not a dropdown but a button, click it
click('Eksportuj')
# Assuming you have a dropdown, use select() to choose an option
# Replace 'myDropdown' with the actual ID of your dropdown
select('Option 2', 'myDropdown')

Add any additional actions you need