java - Getting exception: Unable to locate element -
i trying write script automate login , logout site www.flipkart.com. script failing , giving exception: unable locate element: {"method":"link text","selector":"logout"}
not able figure out issue. can tell issue locator. below code:
actions builder = new actions(driver); system.out.print("log1"); webelement element = driver.findelement(by.xpath(".//*[@id='fk-mainhead-id']/div[1]/div/div[2]/div[1]/ul/li[6]/a")); system.out.print("log2"); action action = builder.movetoelement(element).build(); action.perform(); system.out.print("log3"); driver.manage().timeouts().implicitlywait(5,timeunit.seconds); driver.findelement(by.linktext("logout")).click(); }
you're in luck.. recently, had helped individual logging in , out of flipkart. here script:
@config(url="http://flipkart.com", browser=browser.firefox) public class testflipkart extends conductor { @test public void testloginlogout() { string username = "<username>"; string password = "<password>"; click(by.cssselector("a[href*='/login']")) .settext(by.cssselector("input[name='email']"), username) .settext(by.cssselector("input[name='password']"), password) .click(by.cssselector("input[type='submit'][value='login']")) .validatepresent(by.cssselector("li.greeting-link > a")) .hoverover(by.cssselector("li.greeting-link > a")) .click(by.cssselector("ul.account-dropdown a[href*='/logout']")) // should logged out now. .validatepresent(by.cssselector("a[href*='/login']")); } }
mind you, using conductor framework. can translate css selectors had in there script.
Comments
Post a Comment