TA的每日心情 | 擦汗 2019-6-20 14:56 |
---|
签到天数: 12 天 连续签到: 1 天 [LV.3]测试连长
|
参照1html <div class="row">
<div class="col m2 l2">查询类型</div>
<div class="col m10 l10">
<select id="select_type" name="select_type" class="browser-default">
<option value="0" disabled="" selected="selected">请选择</option>
<option value="1">身份证号</option>
<option value="3">社保号</option>
<option value="2">居民名字</option>
</select>
</div>
</div>
<div class="row">
2.定位选择框中叫做居民名字的选项如下:IDE录制出来的,定位方式
Select(driver.find_element_by_id("select_type")).select_by_visible_text(u"居民名字")
driver.find_element_by_id("CH_Body_btPersonSearch").click()
3.但是执行后,报错如下:
Traceback (most recent call last):
File "D:\zhangyan\test\python\health Record\health_try.py", line 31, in test_add
Select(driver.find_element_by_id("select_type")).select_by_visible_text(u"居民名字")
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 282, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 784, in find_element
'value': value})['value']
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 249, in execute
self.error_handler.check_response(response)
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="select_type"]
请大神指点,这是用IDE录制出来的,定位方式,但是用代码写出来就报错,为啥?
|
|