1

I'm learning automation and I have a few set of login IDs and I'm trying to login and logout in amazon.com website and with a set of login IDs and password which are in a excel file.

Issue what I'm facing is to figure out how to hover over the "hello" in the amazon home page and click on login. I have tried mouse_hover(), click using XPath. However what I want to do is that after I get into the login page I want to login using different login ID and logout again and do the same with different login ID/password.

Here's the code I'm trying to do.

import unittest 

from selenium import webdriver
from selenium.webdriver.support.ui import Select


# create a new Firefox session
driver = webdriver.Firefox()
driver.implicitly_wait(30)
driver.maximize_window()

# navigate to the application home page
driver.get("http://www.amazon.com/")


if  'Sign Out' in driver.page_source:
    pass
else:
    mouse_over("//*[@id='nav-link-yourAccount]")
    hover = driver.find_element_by_xpath("//*[@id='nav-link-yourAccount]")
    hover.click()
    logi = driver.find_element_by_xpath("//*[@id='nav-flyout-ya-signin']")
    logi.click()
#    username = driver.find_element_by_id("login_login_username")
#    username.send_keys("student2")
#    password= driver.find_element_by_id("login_login_password")
#    password.send_keys("Testing1")
#    loginbutton=driver.find_element_by_id("login_submit")
#    loginbutton.click()
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Ghousia
  • 31
  • 3
  • What have you tried? Where is the data source that you're pulling from? The title of your question seems to have nothing to do with the "Issue how to hover over the element hello" – lloyd Jul 22 '15 at 04:05
  • I have 2 blockers here my primary issue is to figure out how to do parameterization on the login page in amazon.com !! But before i get into that page i'm stuck at the hover scenario to click my accouny in the homepage of amazon – Ghousia Jul 22 '15 at 04:22

1 Answers1

1

Remove this line from the code

mouse_over("//*[@id='nav-link-yourAccount]")

Correct x-path-:

hover = driver.find_element_by_xpath("//*[@id='nav-link-yourAccount']")

rest part is ok.

Sandeep
  • 76
  • 2
  • 8