所有,我需要一點點幫助硒等。我似乎無法弄清楚如何等待元素準備就緒。硒等待元素可點擊python
,我需要等待,我可以找到並單擊通過下面的代碼中使用我的腳本元素...
CreateJob = driver.find_element_by_xpath(".//*[@id='line']/div[1]/a")
或
CreateJob = driver.find_element_by_partial_link_text("Create Activity")
我需要等待這個元素在我嘗試點擊元素之前在頁面上可點擊。
我可以使用sleep
命令,但我必須等待5秒或更長時間,它似乎是不可靠的,出錯8次左右出錯1次。
我似乎無法找到正確的語法使用。
爲此的HTML代碼如下。
<document>
<html manifest="https://tddf/index.php?m=manifest&a=index">
<head>
<body class="my-own-class mozilla mozilla48 mq1280 lt1440 lt1680 lt1920 themered" touch-device="not">
<noscript style="text-align: center; display: block;">Please enable JavaScript in your browser settings.</noscript>
<div id="wait" style="display: none;">
<div id="processing" class="hidden" style="display: none;"/>
<div id="loading" class="hidden" style="display: none;"/>
<div id="loadingPartsCatalog" class="hidden"/>
<div id="panel">
<div id="top-toolbar" class="hidden" style="display: block;">
<div id="commands-line" class="hidden" style="display: block;">
<div id="line">
<div class="action-link">
<a class="tap-active" href="#m=activity/a=set" action_link_label="create_activity" component_gui="action" component_type="action">Create Activity</a>
</div>
<div class="action-link">
<div class="action-link">
<div class="action-link">
</div>
<div id="commands-more" style="display: none;">
<div id="commands-list" class="hidden">
</div>
<div id="provider-search-bar" class="hidden center"
工作。任何想法如何基於元素的文本來使用它? – th2112
'element = WebDriverWait(driver,10).until( EC.element_to_be_clickable((By.LINK_TEXT,「Create Activity」)) –
@ th2112 Saurabh是正確的,還有一個By.PARTIAL_LINK_TEXT。 http://selenium-python.readthedocs.io/locating-elements.html – FamousJameous