I'm trying to change the "Adults" value on the Southwest Airlines website using Selenium (Python). I want to be able to specify the number of passengers directly, instead of hitting the +/- buttons. Seems like it should be fairly easy to do, but I can't figure it out. Here is the code I have (not working):
passengers = browser.find_element_by_id('air-pax-count-adults')
passengers.send_keys('3') # Number of passengers
I've also tried the following (doesn't work either):
passengers = browser.find_element_by_id('air-pax-count-adults')
passenges.click()
passengers.send_keys('3') # Number of passengers
Any help would be appreciated. Thanks in advance.
This is a "readonly" input and you have to remove the readonly
attribute in order to be able to interact with it in a traditional way:
passengers = browser.find_element_by_id('air-pax-count-adults')
browser.execute_script("arguments[0].removeAttribute('readonly', 0);", passengers)
passengers.click()
passengers.clear()
passengers.send_keys('3') # Number of passengers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.