3

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")
1
  • 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/…. Commented Mar 2, 2013 at 16:02

1 Answer 1

5

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.