1

I've checked already multiple similar questions and answers, but unfortunately didn't found any solution for my particular case.

Issue description

I'm trying to fill out and submit the form on this site. The form was build as follow:

<form id="hikuZR" action="/historische-kurse/BMW" method="post">
...
<div class="hidden"><input type="submit" value="senden"></div>
<span class="button bgBlue btn-xs-block pull-sm-right" onclick="submitForm($(this));">Historische Kurse anzeigen</span>
</div>
<input type="hidden" name="pkBHTs" value="1550956687">
</form>

This is how I'm performing it:

Filling out the form

start_day_1 = self.driver.find_element_by_xpath("//select[@name='inTag1']/option[@value=22]")
    start_day_1.click()
    start_day_2 = self.driver.find_element_by_xpath("//select[@name='inTag2']/option[@value=22]")
    start_day_2.click()
    start_month_1 = self.driver.find_element_by_xpath("//select[@name='inMonat1']/option[@value=08]")
    start_month_1.click()
    start_month_2 = self.driver.find_element_by_xpath("//select[@name='inMonat2']/option[@value=08]")
    start_month_2.click()
    start_year_1 = self.driver.find_element_by_xpath("//select[@name='inJahr1']/option[@value=2018]")
    start_year_1.click()
    start_year_2 = self.driver.find_element_by_xpath("//select[@name='inJahr2']/option[@value=2018]")
    start_year_2.click()
    try:
        market = self.driver.find_element_by_xpath("//select[@name='strBoerse']/option[@value='%s']" % 'XETRA')
        market.click()
        sleep(randint(7, 10))
    except NoSuchElementException:
        print("Element by xpath does not exist!")

This part works fine, and I'm able to put all values to the form: enter image description here

Clicking on the Button:

I'm trying to locate the button by XPATH as well:

hist_button = self.driver.find_element_by_xpath("//span[contains(.,'Historische Kurse anzeigen')]")

and to click on this button, which seems to be found: enter image description here

hist_button.click()

It doesn't work for me. I've tried also performing the button by executing the script as proposed in some answers on SO:

self.driver.execute_script("arguments[0].click();", hist_button)

Also this solution doesn't work in my case. The page has been refreshed, but didn't show me the result for the historical dates: enter image description here

This is what I see after manual clicking on the button: enter image description here

Could you please help me to find out, what I'm doing wrong? Thank you.

Update 25.02.2018

As suggested in the comment, I'm selecting the values from DropDown lists with the Select class as follow:

start_day_1 = Select(self.driver.find_element_by_xpath("//select[@name='inTag1']"))
start_day_1.select_by_value("22")
start_day_2 = Select(self.driver.find_element_by_xpath("//select[@name='inTag2']"))
start_day_2.select_by_value("22")
start_month_1 = Select(self.driver.find_element_by_xpath("//select[@name='inMonat1']"))
start_month_1.select_by_value("8")
start_month_2 = Select(self.driver.find_element_by_xpath("//select[@name='inMonat2']"))
start_month_2.select_by_value("8")
start_year_1 = Select(self.driver.find_element_by_xpath("//select[@name='inJahr1']"))
start_year_1.select_by_value("2018")
start_year_2 = Select(self.driver.find_element_by_xpath("//select[@name='inJahr2']"))
start_year_2.select_by_value("2018")
market = Select(self.driver.find_element_by_xpath("//select[@name='strBoerse']"))
market.select_by_value('XETRA')

And I'm seeing the selected values in the form (with the "first" version posted in the description, I saw the values in the form as well). After that I'm clicking the button again without any effects. The page was refreshed, but I don't see the results:

hist_button = self.driver.find_element_by_xpath("//span[contains(.,'Historische Kurse anzeigen')]")
hist_button.click()
html_historical = self.driver.page_source

or

hist_button = self.driver.find_element_by_xpath("//span[contains(.,'Historische Kurse anzeigen')]")
self.driver.execute_script("arguments[0].click();", hist_button)
html_historical = self.driver.page_source

enter image description here

When I click on the button manually, the result for selected data will show correctly. It looks like the performing of the button is not working.

  • The problem is that your code isn't changing the values of the dropdowns and when you click on the button with default values, the date range is today to today and there are no values returned. Look at [this answer](https://stackoverflow.com/a/28613320/2386774) that describes the right way to select a value from a dropdown (`SELECT` element), set the values accordingly, and then click the button and you should get results. – JeffC Feb 24 '19 at 00:00
  • @JeffC: Thank you for the suggestion. I'm trying the selection from DropDown List as proposed in [this link](https://stackoverflow.com/a/28613320/5546080): `start_day_1 = Select(self.driver.find_element_by_xpath("//select[@name='inTag1']")) start_day_1.select_by_value("22") ` After that I'm clicking on the button as described in the question without any effect. Still I cannot see the results for selected values. Do I miss something else? Thanks – Robert Ozga Feb 24 '19 at 20:33
  • Update the question with your current code so we can see. Are you seeing the values updating? e.g. 22 is showing in the dropdown now? – JeffC Feb 24 '19 at 21:26
  • @JeffC I've updated the question and yes, I'm seeing the selected values in the form. Thanks. – Robert Ozga Feb 25 '19 at 07:19

0 Answers0