1

I'm trying to sign into a website but the problem is that it doesn't work until I hover the mouse pointer over it.

I have tried this

loginform = driver.find_element_by_id('loginDiv')       
if loginform.get_attribute('style') == 'display: none;':
    print "check!!"
    email = driver.find_element_by_id('username')
    passwd = driver.find_element_by_id('passwd')
    email.send_keys('my_email')
    passwd.send_keys('my_pass')
    passwd.send_keys(Keys.RETURN)

As I said, I'm able to login through this script only when I hover mouse(I mean first I run this script and see if page is completely loaded and then I quickly move my mouse over login button and I can see my login detail is being typed by this script, but other way if I don't hover it won't be able to log in).

4 Answers 4

1

Iam not sure but once try this

     options=driver.find_elements_by_class_name("user_area")
     for option in options:
         if(option.text=="Login")
              option.click()
              time.sleep(3)
              option.click()
     email = driver.find_element_by_id('username')
     passwd = driver.find_element_by_id('passwd')
     email.send_keys('my_email')
     passwd.send_keys('my_pass')
     passwd.send_keys(Keys.RETURN)

I wrote option.click() twice because in your site first click making the login form dissapear. So second click may help us..

Sign up to request clarification or add additional context in comments.

Comments

1

I have solved it this way:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://pythondev.zyante.com/")
loginForm = driver.find_element_by_id("user_area")
loginLink = loginForm.find_element_by_tag_name("a")
webdriver.ActionChains(driver).move_to_element(loginLink).perform()
email = driver.find_element_by_id('username')
email.send_keys('my_email')
passwd = driver.find_element_by_id('passwd')
passwd.send_keys('my_pass')
button = loginForm.find_element_by_class_name("loginButton")
webdriver.ActionChains(driver).move_to_element(button).click().perform()

Above code works for me.

Comments

0

I have done the similar thing in Java using a class called JavascriptExecutor. Using this class you can execute the javascript. You can use the javascript to click or handle the hidden elements without opening the window. Not sure if same present in Python.

Comments

0

Performed the below login in JAVA using selenium-webdriver, hope it applies to Python also.

Before you perform your login operation the mouse hover has to be performed on the login element.

Actions action = new Actions(driver);
WebElement e=driver.findElement(By.id("user_area"));

//action.moveToElement(e).build().perform();  

Above command fails to open the Login popup because by default the hover on any element is performed on the center. Unfortunatey on the UI the Login|Request Access|Help is a single html element with id="user_area", and during hovering automatically the moves to the center thus highlighting Request Access.

action.moveToElement(e,10,0).build().perform();

So, the above statement is used to give an offset from the top-left corner of the element and hovering on the Login.

For furthur reading on advanced mouse actions using selenium-webdriver refer the below link http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html

Check for the function moveToElement to understand it better.

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.