2013-03-02 2 views
3

저는 Python과 Selenium에 매우 익숙합니다.Selenium/Python - 사용자 이름 필드에 텍스트를 입력 할 수 없습니다.

페이지가로드되고 사용자 이름과 암호 필드가 완성되는 자동화 된 스크립트를 만들려고합니다.

Selenium에서 자동화를 실행하면 잘 작동하지만 (간단한 프로세스 임), 파이썬 서버를 통해 실행할 때 작동하지 않습니다. 페이지가로드되지만 입력란은 채워지지 않습니다.

도움을 주셨습니다.

from selenium import webdriver 
from selenium.webdriver.common.by import By 
from selenium.webdriver.support.ui import Select 
from selenium.common.exceptions import NoSuchElementException 
import unittest, time, re 

class Pageload(unittest.TestCase): 
    def setUp(self): 
     self.driver = webdriver.Firefox() 
     self.driver.implicitly_wait(30) 
     self.base_url = "http://gymbox.com/" 
     self.verificationErrors = [] 
     self.accept_next_alert = True 

    def test_pageload(self): 
     driver = self.driver 
     driver.get(self.base_url + "/Login") 
     driver.find_element_by_id("login_Email").clear() 
     driver.find_element_by_id("login_Email").send_keys("hello") 
+0

당신이 FEX의 Chromes 개발자 도구를 사용하여 소스를 선택하면, 당신은 당신이 찾고있는 요소가 포함 된 iframe 내에서 발견되는 것을 볼 수 있습니다. 이는 http://stackoverflow.com/questions/15047743/selenium-webdriver-unable-to-find-element-by-id-using-python/15053287#15053287과 유사합니다. – TAS

답변

5

키를 입력 할 수 없습니다. iframe에 넣기 때문에 입력 할 수 없습니다. driver.switch_to_frame()을 실행하고 나머지 스크립트를 실행하십시오. 여기에 예를

:

def test_pageload(self): 
driver = self.driver 
driver.get(self.base_url + "/Login") 
driver.switch_to_frame('iframe') #<iframe> is the ID of your iframe 
driver.find_element_by_id("login_Email").clear() 
driver.find_element_by_id("login_Email").send_keys("hello") 
관련 문제