0

Login_Via_Email_Button

In the image above I am trying to click the 'Continue with email' button. This is the code I have:

from selenium import webdriver

Driver = webdriver.Firefox() #Define webdriver to use
Driver.get('https://www.airbnb.co.uk/login')
Element = Driver.find_element_by_xpath("//div[contains(@class,'_p03egf') and (@class, '_18m31f1b')]")
Element.click

Either my syntax is wrong or my poor understanding of web pages is letting me down

Any help - much appreciated

Thanks Rob

4 Answers 4

1

You can use below solutions, if you want to click on a Continue with email button:

- XPATH

Example 1

wait = WebDriverWait(Driver, 30)
     wait.until(EC.presence_of_element_located((By.XPATH, "//div[contains(text(),'Continue with email')]"))).click()

Example 2

wait = WebDriverWait(Driver, 30)
     wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class='_bc4egv gs_copied']"))).click()

- CSS Selector

 wait = WebDriverWait(Driver, 30)
     wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".\_18m31f1b:nth-child(1) .\_bc4egv"))).click()

Dont forget to add below imports

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Sign up to request clarification or add additional context in comments.

2 Comments

Lovely - the 1st example worked a treat (just capital D as I'd capitalised 'Driver' object in my code). Thanks very much
Great !! would you kind enough to accept answer from your end.
1

I think your XPath is off, from the example you gave, I would assume you want something like this:

Element = Driver.find_element_by_xpath("//button[@data-testid='social-auth-button-email']")

w3schools.com has a great tutorial on XPath syntax

1 Comment

Thank you - there seemed to be a timing issue, but once past that your syntax was good
0

Can you try this code

Element = Driver.find_element_by_xpath('//*[@id="site-content"]/div/div/div/div/div/div/div/div[2]/button')

Comments

0
find_elements_by_class_name('_18m31f1b').click()

It should be enough to do what you want as the button seems to be connected to that class and all you want to do is click it.

Comments

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.