Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm very new to Python and Selenium.

I'm trying to create an automated script where a page is loaded and username and password fields are completed.

When I run the automation in Selenium, it works fine (it's a simple process), but when I run it through the python server it doesn't work. The page loads, but no fields are populated.

Any help appreciated!

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")
share|improve this question
    
If you check the source using the fex Chromes developer tools, you will see that the element you are looking for is found inside an embedded iframe. This is similar to this stackoverflow.com/questions/15047743/…. –  TAS Mar 2 '13 at 16:02
add comment

1 Answer

You can't enter the key because of it is put in an iframe. Try driver.switch_to_frame() then execute the rest scripts.

Here the example:

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")
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.