1

My python program with selenium has a strange behavior : it works very good when I start it in debug mode but not in normal mode. The FromDate is not taken into account in normal mode.

I thought it was a timing problem and I put several wait (explicit and implicit wait) with no difference. Note that the button is a submit and not a click. Any Idea to solve this issue ?

url = "https://my.elexys.be/MarketInformation/SpotBelpex.aspx"
driver = webdriver.Chrome()
driver.get(url)
FromDate = driver.find_element("name", "ctl00$contentPlaceHolder$fromASPxDateEdit")
FromDate.clear()
FromDate.send_keys("01/11/2023")
UntilDate = driver.find_element("name", "ctl00$contentPlaceHolder$untilASPxDateEdit")
UntilDate.clear()
UntilDate.send_keys("01/12/2023")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "ctl00$contentPlaceHolder$refreshBelpexCustomButton")))
ShowData_button = driver.find_element("name", "ctl00$contentPlaceHolder$refreshBelpexCustomButton")
ShowData_button.submit()
1
  • maybe first check what you get in driver.page_source. Maybe server sends different content - ie. some warning or captcha. Commented Dec 17, 2023 at 11:10

1 Answer 1

0

Your clicking on show data button too fast - changes are entered, but not applied as an input event.

To simulate input event more close to user flow, I suggest to add smth like pressing enter.

from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait

url = "https://my.elexys.be/MarketInformation/SpotBelpex.aspx"
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
action_chains = ActionChains(driver)

driver.get(url)
FromDate = driver.find_element("name", "ctl00$contentPlaceHolder$fromASPxDateEdit")
FromDate.clear()
FromDate.send_keys("01/11/2023")
action_chains.send_keys(Keys.ENTER).perform()

UntilDate = driver.find_element("name", "ctl00$contentPlaceHolder$untilASPxDateEdit")
UntilDate.clear()
UntilDate.send_keys("01/12/2023")
action_chains.send_keys(Keys.ENTER).perform()

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "ctl00$contentPlaceHolder$refreshBelpexCustomButton")))
ShowData_button = driver.find_element("name", "ctl00$contentPlaceHolder$refreshBelpexCustomButton")
ShowData_button.submit()
Sign up to request clarification or add additional context in comments.

1 Comment

@JeanMarcCanon can you plz check this answer as "correct" if it resolves your issue? :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.