Have been trying to set up code for scraping a web page in Python. However, I can't find the code, that helps me identify the "Submit" button in the source code of the web page. See the source code here:
What I have tried so far includes:
log_in_button = driver.find_element_by_css_selector('button.submit')
log_in_button = driver.find_element_by_link_text('Log in')
log_in_button = driver.find_element_by_class_name('buttonstyle__Button-sc-11cbuc5-1 kfFBYh styled__SubmitButton-sc-voms4e-4 jPKYnl')
Also have tried the following, it works, but then a different button to the one I want (in the code it is before the button that I want) is clicked.
log_in_button = driver.find_element(By.XPATH, '//button')
Any suggestions on what else I could try, besides the mentioned? Sorry if I haven't got the terminology 100% correct yet, just starting out here. Hope it is clear nevertheless.
CodePudding user response:
log_in_button = driver.find_element_by_css_selector('button.submit')
This does describe button element with class submit, i.e. something like <button >
whilst you have button with submit
type, which in CSS selector language is button[type=submit]
, so your code shoule be
log_in_button = driver.find_element_by_css_selector('button[type=submit]')