I want to locate an element in selenium using css selector, and I use the program "copy css selector" and got:
div>button[type ="submit"]
Is this correct?
submit_button = driver.find_element_by_css_selector("input[type='submit']")
I want to locate an element in selenium using css selector, and I use the program "copy css selector" and got:
div>button[type ="submit"]
Is this correct?
submit_button = driver.find_element_by_css_selector("input[type='submit']")
Yes, the Locator Strategy below:
submit_button = driver.find_element_by_css_selector("input[type='submit']")
is syntactically correct. But as per the copy css selector it should have been:
submit_button = driver.find_element_by_css_selector("div > button[type='submit']")
Note:
find_element_by_*
commands are deprecated. Please use find_element() instead
Accordingly you can also use:
submit_button = driver.find_element(By.CSS_SELECTOR, "input[type='submit']")
As per copy css selector:
submit_button = driver.find_element(By.CSS_SELECTOR, "div > button[type='submit']")