创建 def 检查 URL 是否有效(如果未找到)转到不同的 URL 编辑该字段,但检查当前 URL 然后提取正确的信息
Create def Check if a URL is Vaild if it is not found go to a different URL to edit that field but check the current URL then pull the correct info
尝试创建 def 检查 URL 是否有效(如果未找到)转到另一个 URL 按下按钮编辑该字段但检查当前 URL 然后从配置中提取正确的信息并发送到文本字段
下面是我正在看的
<tbody><tr>
<th width="150">License Key *</th>
<td width="1">:</td>
<td><input type="text" name="LicenseKey" value="" size="80" maxlength="64"></td>
</tr>
</tbody>
>
def licenses(value):
try:
gotoURL(builder+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(base_url+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(server1+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(server2+value)
except NoSuchElementException:
pressButton(license_edit)
if driver.current_url(builder):
sendKeys(license_key,server_license)
if driver.current_url(base_url):
sendKeys(license_key,serverlicense)
if driver.current_url(zach_server):
sendKeys(license_key,server_license1)
if driver.current_url(michael_server):
sendKeys(license_key,server_license2)
这是我遇到的错误 TypeError
我猜你遇到了 typeError 因为
driver.find_element_by_xpath()
returns 一个 WebElement,无论出于何种原因都无法转换为您的 if 语句的布尔值。尝试切换到
driver.find_elements_by_xpath()
即使只找到一个元素,此方法仍然有效,它只是 returns 一个包含该元素的数组。这很重要,因为 python 能够看到长度为 1+ 的数组(如果找到一个或多个元素)并将其转换为布尔值。
尝试创建 def 检查 URL 是否有效(如果未找到)转到另一个 URL 按下按钮编辑该字段但检查当前 URL 然后从配置中提取正确的信息并发送到文本字段 下面是我正在看的
<tbody><tr>
<th width="150">License Key *</th>
<td width="1">:</td>
<td><input type="text" name="LicenseKey" value="" size="80" maxlength="64"></td>
</tr>
</tbody>
>
def licenses(value):
try:
gotoURL(builder+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(base_url+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(server1+value)
if driver.find_element_by_xpath('//*[@id="main-message"]/h1/span'):
gotoURL(server2+value)
except NoSuchElementException:
pressButton(license_edit)
if driver.current_url(builder):
sendKeys(license_key,server_license)
if driver.current_url(base_url):
sendKeys(license_key,serverlicense)
if driver.current_url(zach_server):
sendKeys(license_key,server_license1)
if driver.current_url(michael_server):
sendKeys(license_key,server_license2)
这是我遇到的错误 TypeError
我猜你遇到了 typeError 因为
driver.find_element_by_xpath()
returns 一个 WebElement,无论出于何种原因都无法转换为您的 if 语句的布尔值。尝试切换到
driver.find_elements_by_xpath()
即使只找到一个元素,此方法仍然有效,它只是 returns 一个包含该元素的数组。这很重要,因为 python 能够看到长度为 1+ 的数组(如果找到一个或多个元素)并将其转换为布尔值。