I am struggling on how to get the button type element in this example, so that I can be able to test it using selenium in python.
JavaScript
x
2
1
<button class="login-button signin-button button-primary" type="submit"><div class="signin-text">Sign in</div></button>
2
My Code:
JavaScript
1
22
22
1
from selenium import webdriver
2
from selenium.webdriver.common.keys import Keys
3
from selenium.webdriver.chrome.service import Service
4
5
import time
6
7
8
PATH = Service("C:Program Files (x86)chromedriver.exe")
9
driver = webdriver.Chrome(service=PATH)
10
11
driver.get("https://www.dropbox.com/login")
12
13
14
driver.find_element("name", "login_password").send_keys("123456")
15
driver.find_element("type", "submit").send_keys(Keys.ENTER)
16
17
time.sleep(5)
18
driver.close()
19
20
21
print("Test Completed Successfully ")
22
I think the code changed because of the selenium version? I need help guys Thank you.
Advertisement
Answer
There is no such selector type as "type"
. You can either use another locator for Submit button e.g.
JavaScript
1
2
1
driver.find_element("xpath", "//button[@type='submit']").send_keys(Keys.ENTER)
2
or this form submitting approach
JavaScript
1
4
1
input_field = driver.find_element("name", "login_password")
2
input_field.send_keys("123456")
3
input_field.submit()
4