2016-08-05 3 views
1

내가 다음 코드에 문제가 있어요 :파이썬 셀레늄 excpected 조건 send_keys

iFrame = EC.frame_to_be_available_and_switch_to_it(("MAIN_IFRAME")) 
uscita = EC.presence_of_element_located((By.XPATH, "//input[contains(.,'password')]")) 
uscita.send_keys('passwd') 

을하고 난 다음 오류 받고 있어요 :

AttributeError: 'presence_of_element_located' object has no attribute 'send_keys' 

을 나는 새 파이썬의 사용자와 I 해요 이 문제에 도움을 청합니다.

감사와 iframe 입력

HTML은 :

<td style="text-align:center"> 
    <iframe height="350" width="450" name="timb" src="timb.php" style="position: relative;top:0px"></iframe> 
</td> 
<td> 
    <div style="position: relative;top:0px"> 

     <form action="mnghlog6.php" method="post" target="timbri"> 
      <input type="hidden" id="esculappio" name="escu" value="0"> 
      <table style="position: relative;top:0px"> 
      </div></td><td><div class="buttons" style="display:inline;text-align: left;"> 
      </div></td></tr><tr><td><div class="buttons" style="display:inline;text-align: left;"> 
      </div></td><td><div class="buttons" style="display:inline;text-align: left;"> 
      </div></td></tr></tbody></table>     </div> 
       </td> 
      </tr> 
      <tr> 
       <td style="text-align:center">Password <input type="password" name="password" id="password" size="30" value=""></td> 
      </tr> 
      </tbody></table> 
      <input type="hidden" name="tipo" value=""> 
      <input type="hidden" name="flag_inizio"> 
      <input type="hidden" name="durata"> 
     </form> 
    </div> 
</td> 
</tr> 
+1

같은 것을 할 수있는 프레임으로 전환, 그런데이

wait = WebDriverWait(driver, 10); uscita = wait.until(EC.presence_of_element_located((By.ID, "password"))) uscita.send_keys('passwd') 

시도 presence_of_element_located'는 대기중인 요소를 사용하기 위해 해결해야하는 '명시 적 대기'를 반환합니다. –

+0

프레임 및 입력 용으로 HTML을 공유 할 수 있습니까? –

+0

여기에서 허용되지 않았기 때문에 html의 일부 코드가 생략되었습니다. –

답변

1

당신은 expected_conditionsWebDriverWait에서 until 기능을 사용해야합니다. 필드가 iframe 인 것처럼 보이지 않습니다. http://selenium-python.readthedocs.io/waits.html `에서 봐 당신이

iFrame = wait.until(EC.frame_to_be_available_and_switch_to_it((By.NAME, "timb"))) 
+0

이것을 시도하면 TimeoutException이 발생합니다. –

+0

@ ErrolBane 어디서? 또한 해당 html을 추가하십시오. – Guy

+0

@ErjolBane'frame_to_be_available_and_switch_to_it'는 locator를 얻어야합니다. 문자열이 아닙니다. 'presence_of_element_located'와 같습니다. – Guy