0

Trying to submit the check in form for United Airlines (https://www.united.com/en/us/checkin). I can't get the continue button to automate. The xpath is dynamic so is css selector. Can't find a name or id browser to find. How can I find this element? Never coded before so this is all I have been able to pickup from youtube

html for button

<button class="app-components-Button-styles__button--LbfHO app-components-Button-styles__tertiary--20H47 app-components-Button-styles__contained--2kXyi" type="submit">Continue</button>

Code so far:

from selenium import webdriver

browser = webdriver.Chrome('/Users/jeff/chromedriver/chromedriver')

browser.get('https://www.united.com/en/us/checkin')

browser.find_element('name', 'confirmationNumberModel.number').send_keys('AAAA1')

browser.find_element('name', 'confirmationNumberModel.lastName').send_keys('LastName')

browser.implicitly_wait(3)
LMC
  • 10,453
  • 2
  • 27
  • 52
jtg
  • 1

2 Answers2

0

Try to locate button by XPath:

browser.find_element(By.XPATH, '//button[.="Continue"]').click()

You can also call submit method from any element inside form node:

browser.find_element('name', 'confirmationNumberModel.lastName').submit() 

P.S. Note that browser.implicitly_wait(3) should be called before locating elements

JaSON
  • 4,843
  • 2
  • 8
  • 15
0

Given the HTML:

<button class="app-components-Button-styles__button--LbfHO app-components-Button-styles__tertiary--20H47 app-components-Button-styles__contained--2kXyi" type="submit">Continue</button>

All the classnames are dynamically generated. So we can't use them and have to look out for the static element attributes.


Solution

To click on Continue you can use either of the following locator strategies:

  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "div[title='Confirmation or eTicket number'] button[type='submit']").click()
    
  • Using xpath:

    driver.find_element(By.XPATH, "//button[@type='submit' and text()='Continue']").click()
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • THanks undetected Selenium! Your xpath worked, but now once the button is clicked, it doesn't generate the following webpage to continue the check in process. The age begins to load and then automatically stops. Any idea why? – jtg Aug 13 '22 at 18:48
  • Hmmm, need to look at the DOM to understand what's happening out there. Feel free to raise a new question for your new requirements. – undetected Selenium Aug 13 '22 at 21:00