小编Gal*_*hum的帖子

硒无法通过名称或ID查找元素(Python)

from selenium import webdriver
import os
from selenium.webdriver import chrome

driver = webdriver.Chrome()
driver.get("http://nmcunited.me.showenter.com/%D7%9C%D7%94-%D7%9C%D7%94-%D7%9C%D7%A0%D7%93.html")
driver.implicitly_wait(15)
christmasTag = driver.find_element_by_id('f_2561406_1')
christsmasTag.click()
driver.close()
Run Code Online (Sandbox Code Playgroud)

我使用上面的python代码来练习一些基本的Selenium操作。我找不到任何元素,无论是名称还是ID。无论我尝试什么,我总是会遇到相同的错误,该错误表明我要查找的元素不存在。(想法是按一下其中一个按钮...)

这是网站html代码的一部分:

<!-- main page -->
<td 
valign="top">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- Page Content -->
<!-- Page Content -->
<tr>
<td valign="top">
<table border="0" width="100%" cellpadding="3" cellspacing="0">
<tr>
<!-- the form -->
<td valign="top">
<form id="form2" name="form2" method="post" action="/site/form/sendForm.asp" OnSubmit="return CheckSubmit();" enctype="multipart/form-data">
<!-- Form Field List -->
<table id='sop_form_594602' class='sop_all_form' align="center" border="0" width="100%" cellpadding="3" cellspacing="0" 
>
<tr>
<td …
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-webdriver

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

selenium ×1

selenium-webdriver ×1