0

I am trying to automate logging into this website.

the login menu is at the top right of the website.

i have tried to find the login form by CSS selector, Xpath, name and the action of this topic.

edit 1 : I have also tried hover the mouse over the login with actionchains then find by elements. No Element was found, no key was sent also.

Result:

the find by CSS, Xpath, name shows : element not visible ; the action event : i hover the mouse over the login area, send keys,the login area pops up but no key was sent, no error shown.

My code for the action event:

wd.get("http://www.vatgia.com")

action = ActionChains(wd);

action.move_to_element(wd.find_element_by_css_selector("#header_bar > div > div.fr > a:nth-child(8)"))
action.send_keys("loginsampling")

action.perform();

p/s : thankyou Brian for the edit !

Final update :

Mahipal has provided me with the solution. i should have used the xpath with regards to the container for the login form and password. i previously only right click and copy the xpath element and that did not work. Thanks Mahipal !

Community
  • 1
  • 1

2 Answers2

0

This is due to the fact that you are not opening the login dropdown prior to attempting to find the login button. You will need to find the Dropdown element, click on it, then find the login fields and button and perform your actions.

Moe Ghafari
  • 2,227
  • 1
  • 12
  • 17
  • i did, i found the element of the drop down. In the find by Elements, i clicked on it and attempted to find the login form. In the Action i hover the mouse over it then attempted to send keys. – Kien Nguyen Trung Apr 12 '17 at 22:01
0

You can make use of the container of login menu for identifying its fields, as shown below:

driver.findElement(By.xpath("//div[@id='header_bar']//a[@rel='#header_login']")).click();

WebDriverWait wait = new WebDriverWait(driver, 10);

wait.until(ExpectedConditions.visibilityOf(
                driver.findElement(By.xpath("//div[@id='simple_tip']//div/input[@name='loginname']"))));

driver.findElement(By.xpath("//div[@id='simple_tip']//div/input[@name='loginname']")).sendKeys("login_name");

Try above code and let me know, whether it works for you.

Mahipal
  • 900
  • 1
  • 5
  • 7