Reputation: 109
I'm trying to use Selenium
to create a new message in my mailbox. I have a problem with finding napisz
(en: 'write') button on my e-mail website. I tried to use driver.find_element_by_link_text
but it doesn't work. I've managed to go workaround this problem using xpath
but I'm very curious why the first method fails.
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('https://profil.wp.pl/login.html?zaloguj=poczta&url=https://poczta.wp.pl/profil/')
elem_login = browser.find_element_by_name('login_username')
elem_login.send_keys('[email protected]')
elem_password = browser.find_element_by_name('password')
elem_password.send_keys('thankyouforhelp')
elem_zaloguj_button = browser.find_element_by_id('btnSubmit')
elem_zaloguj_button.click()
browser.get('https://poczta.wp.pl/d635/indexgwt.html#start')
elem_napisz_button = browser.find_element_by_link_text('napisz')
elem_napisz_button.click()
EDIT: I've tried to used same xpath
today but it failed. Is it possible that it's somehow dynamic causing the problem?
Upvotes: 1
Views: 733
Reputation: 474161
.find_element_by_link_text()
looks for a
elements only. In your case, this is the button
element and cannot be located using this locator.
Upvotes: 3