第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

硒 Web 驅(qū)動(dòng)程序 - 無(wú)法找到元素?

硒 Web 驅(qū)動(dòng)程序 - 無(wú)法找到元素?

烙印99 2022-08-11 17:11:13
法典from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECchrome = webdriver.Chrome(executable_path= 'C:\webdriver.exe\chromedriver.exe',port=9515)url = 'https://protonmail.com/'chrome.get(url)chrome.implicitly_wait(10)chrome.find_element_by_xpath('//*[@class="btn btn-default btn-short"]').click()chrome.find_element_by_class_name("panel-heading").click()chrome.find_element_by_id("freePlan").click()chrome.find_element_by_id('username')chrome.find_element_by_id("password").send_keys('password')chrome.find_element_by_id("passwordc").send_keys('password')斷續(xù)器<input placeholder="Choose username" required="" name="username" messages="[object Object]" iframename="top" pattern=".{1,40}" id="username" class="input">問(wèn)題chrome.find_element_by_id('username')我正在嘗試輸入用戶名;但是,python說(shuō)它找不到該元素,即使我正在使用它給你的用戶名id。
查看完整描述

2 回答

?
qq_花開(kāi)花謝_0

TA貢獻(xiàn)1835條經(jīng)驗(yàn) 獲得超7個(gè)贊

我剛剛修改了你的代碼,現(xiàn)在它的工作原理:


from selenium import webdriver


from selenium.webdriver.common.keys import Keys


from selenium.webdriver.support.ui import WebDriverWait


from selenium.webdriver.support import expected_conditions as EC


import time


chrome = webdriver.Chrome(executable_path= 'C:\webdriver.exe\chromedriver.exe',port=9515)


url = 'https://protonmail.com/'


chrome.get(url)


chrome.implicitly_wait(10)


chrome.find_element_by_xpath('//*[@class="btn btn-default btn-short"]').click()


chrome.find_element_by_class_name("panel-heading").click()


chrome.find_element_by_id("freePlan").click()


time.sleep(10)


#chrome.find_element_by_xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "top", " " ))]')


chrome.switch_to.frame(chrome.find_element_by_xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "top", " " ))]'))

typeinput = chrome.find_element_by_xpath('//*[@id="username"]')

typeinput.click()

typeinput.clear()

typeinput.send_keys('password')


chrome.switch_to.default_content()


chrome.find_element_by_id("password").send_keys('password')


chrome.find_element_by_id("passwordc").send_keys('password')


查看完整回答
反對(duì) 回復(fù) 2022-08-11
?
溫溫醬

TA貢獻(xiàn)1752條經(jīng)驗(yàn) 獲得超4個(gè)贊

在AUT中模擬動(dòng)作時(shí),還有其他事情需要注意。即微調(diào)器和裝載機(jī)。所以你也需要處理這些。


在你的代碼中引入。據(jù)觀察,在單擊“注冊(cè)”按鈕時(shí),它開(kāi)始顯示加載程序,然后顯示計(jì)劃,以便處理下面的代碼使用,直到該加載程序被隱藏,然后執(zhí)行單擊所需的計(jì)劃。ExplicitWait


chrome.find_element_by_xpath('//*[@class="btn btn-default btn-short"]').click()

WebDriverWait(chrome, 20).until(EC.invisibility_of_element_located((By.ID, "redir"))

chrome.find_element_by_css_selector("div[aria-controls='plan-free']").click()

在執(zhí)行單擊按鈕時(shí),它會(huì)重定向到新頁(yè)面并顯示新頁(yè)面加載在那里,然后加載注冊(cè)表單。使用下面的代碼 -Free Plan


WebDriverWait(chrome, 10).until( EC.invisibility_of_element_located((By.ID, "pm_slow"))

注冊(cè)表單中的用戶名在 iframe 下加載,因此您需要先切換到 iframe,然后執(zhí)行進(jìn)一步的操作


username_frame = chrome.find_element_by_xpath("//div[@class='usernameWrap']//iframe[@title='Registration form']")

chrome.switch_to.frame(username_frame)

WebDriverWait(chrome, 10).until( EC.visibility_of_element_located((By.ID, "username"))

chrome.find_element_by_id('username').send_keys(‘username’)

chrome.switch_to.default_content()

chrome.find_element_by_id("password").send_keys('password')

chrome.find_element_by_id("passwordc").send_keys('password')


查看完整回答
反對(duì) 回復(fù) 2022-08-11
  • 2 回答
  • 0 關(guān)注
  • 111 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)