1

So I'm trying to get the value inside a button using selenium.

My code is:

getphone = profile.find_element_by_class_name('app-emp-phone-txt').click().find_element_by_tag_name("p")

But I'm getting this error:

AttributeError: 'NoneType' object has no attribute 'find_element_by_tag_name'

What should I write in my code ?

thanks a lot :)

1 Answer 1

1

You're trying to call find_element from method (click) call which returns None. Try to update your code:

getphone = profile.find_element_by_class_name('app-emp-phone-txt')
getphone.click()
getphone.find_element_by_tag_name("p")

Update

from selenium import webdriver

driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.get('https://www.mariages.net/domaine-mariage/la-tour-des-plantes--e129089')

getphone = driver.find_element_by_class_name('app-emp-phone-txt')
getphone.click()
number = driver.find_element_by_css_selector(".app-dropdown-show-phone>.storefrontDrop__tag").text
print(number)
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the answer! The problem is I'm getting this error now: NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"p"} (Session info: chrome=88.0.4324.146)
@DylanG probably you need to use Wait. Its hard to tell without seeing page
@DylanG what exactly you want to get as output?

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.