python-2.7 - 找不到链接
问题描述
我正在尝试单击网页上的选项卡(区域监管):https ://www5.fdic.gov/idasp/advSearchLanding.asp
但是,它不识别该命令。在这里,我附上了代码。
import urllib2
import urllib
from bs4 import BeautifulSoup
import subprocess
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome("/usr/local/bin/chromedriver")
import time
s1_url = 'https://www5.fdic.gov/idasp/advSearchLanding.asp'
browser.get(s1_url)
问题:选择监管区域选项卡,但没有单击它。
browser.find_element_by_xpath('//[@id="Banks_Regulatory_Tab"]/a').click()
有一个例外:
NoSuchElementException:消息:没有这样的元素:无法找到元素:{"method":"xpath","selector":"//*[@id="Banks_Regulatory_Tab"]/a"}
解决方案
位于 iframe 内的必需元素。为了能够处理它,您需要切换到该 iframe:
browser.switch_to.frame("content")
browser.find_element_by_link_text("Regulatory Regional").click()
推荐阅读
- python - Make a new list in CSV without using pandas: return UnicodeDecodeError
- java - System.console() returning null in Command line during mvn test
- python-3.x - How to check if tree is symmetric python
- php - How to get the last inserted ID from MSSQL server?
- angular - 将下拉列表的选定 ID 绑定到输入并将其视为默认值
- solr - Does solr replication not work while data import is in progress on master?
- r - 为 ML 相关的网页抓取加载数千个 URL - 代码非常慢,需要效率提示
- java - 字符串 .replace() 不适用
- google-cloud-firestore - How to write Firestore Rule to allow admin access
- git - 我从本地删除文件而不是丢弃本地更改