"selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable"这是我无缘无故得到的错误。我的意思是早些时候它曾经工作但现在不是。在我的代码中有这个网站:https://www.tempinbox.xyz/ 我使用 chromedriver 打开它。我想要做的是从域的下拉菜单中选择 (@fitschool.be)。并输入一些我存储为变量“str(res)”的变量字符串我的代码是:-second_tab = webdriver.Chrome(options=options,) second_tab.get("https://www.tempinbox.xyz/") randombutton = second_tab.find_element_by_xpath("/html/body/main/div[1]/div/div[1]/div[2]/form[1]/input[2]") #for the email generation randombutton.send_keys(str(res)) mainurl = second_tab.current_url selectoption1=second_tab.find_element_by_id("selected-domain").click() selectoption2=second_tab.find_element_by_css_selector(".domain-selector:nth-child(3)").click() clickfinal= second_tab.find_element_by_xpath("//input[@value='Create']").click() emailentry = str(res)+ "@fitschool.be" print ("your email is " + emailentry)但它给了我错误....Traceback (most recent call last): File "C:\Users\BRS\Desktop\AccountChef\wattpad acc maker.py", line 45, in <module> selectoption2=second_tab.find_element_by_css_selector(".domain-selector:nth-child(3)").click() File "C:\Users\BRS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "C:\Users\BRS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute return self._parent.execute(command, params) File "C:\Users\BRS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response)
1 回答

慕妹3146593
TA贡献1820条经验 获得超9个赞
而不是以下两行:
selectoption1=second_tab.find_element_by_id("selected-domain").click()
selectoption2=second_tab.find_element_by_css_selector(".domain-selector:nth-child(3)").click()
尝试设置 innerHTML 值.execute_script:
element = second_tab.find_element_by_id("selected-domain")
target = "@fitschool.be"
second_tab.execute_script("arguments[0].innerHTML = '{}';".format(target), element)
添加回答
举报
0/150
提交
取消