自动化测试python硒(python 37-32)带有catch元素的问题,我尝试使用class_name css_selector xpath
<input type="text" size="2" class="input et_pb_contact_captcha" data-first_digit="8" data-second_digit="4" value="" name="et_pb_contact_captcha_1" data-required_mark="required" style="" xpath="1">
我尝试过使用class_name
self.driver.find_element_by_class_name("input et_pb_contact_captcha").send_keys("-1")
driver.find_element_by_css_selector("input.input.et_pb_contact_captcha").send_keys("-1");
xpath //input[@name='et_pb_contact_captcha_1']
from selenium import webdriver
import time
import unittest
class CheckTest(unittest.TestCase):
def setUpClass(cls):
cls.driver = webdriver.Chrome("C:\chromedriver_win32\chromedriver.exe")
cls.driver.implicitly_wait(15)
cls.driver.maximize_window()
def test_check_valid(self):
self.driver.get("www.site.com")
self.driver.find_element_by_class_name("input").send_keys("test")
self.driver.find_element_by_class_name("et_pb_contact_message input").send_keys("test")
self.driver.find_element_by_css_selector("input.input.et_pb_contact_captcha").send_keys("-1");
我对此元素有疑问
self.driver.find_element_by_css_selector("input.input.et_pb_contact_captcha").send_keys("-1");
Traceback (most recent call last):
File "C:\Python37-32\automation\testcheck.py", line 11, in <module>
driver.find_element_by_class_name("input et_pb_contact_captcha").send_keys("-1")