java - How to insert text into popup window using selenium WebDriver -


i trying automate web page using selenium webdriver. can move towards webpages , can able tasks on parent pages. @ 1 place getting popup window asks username , password. unable identify username , password text box id's, how can find element (textbox) , send username , password through selenium webdriver code.

you can try using web url,

@test public void testlinkedin() throws exception { driver.get("https://www.linkedin.com/");  //use web url driver.findelement(by.linktext("sign up")).click(); driver.findelement(by.cssselector("button.fb-btn")).click(); thread.sleep(3000);  set <string>handles = driver.getwindowhandles();//to handle multiple windows firstwinhandle = driver.getwindowhandle(); handles.remove(firstwinhandle); string winhandle=handles.iterator().next(); if (winhandle!=firstwinhandle){      secondwinhandle=winhandle;  driver.switchto().window(secondwinhandle);   //switch popup window thread.sleep(2000);  driver.findelement(by.id("email")).clear(); driver.findelement(by.id("email")).sendkeys("username"); driver.findelement(by.id("pass")).clear(); driver.findelement(by.id("pass")).sendkeys("password"); driver.findelement(by.id("u_0_2")).click(); driver.findelement(by.name("__confirm__")).click();} 

make sure declare these string variables as,

public string firstwinhandle;   public string secondwinhandle;  

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -