getting data from notepad

22 views
Skip to first unread message

Praveen Reddy

unread,
Nov 21, 2014, 12:01:24 AM11/21/14
to seleniu...@googlegroups.com
Hi, i have to get multiple data from notepad for login webpage. how i can send multiple loging user data to login page.  check below code, how can i store data into array or string or list with some iteration.
public static void main(String[] args) throws Exception
    {
        String str,a[];
        //int i=0;
        FileReader fr=new FileReader("G:\\gpr\\selenium_pract\\seleniumpgm\\noteyahoo.txt");
        BufferedReader br=new BufferedReader(fr);
        while((str=br.readLine())!=null)
        {
        int i=0;
            while(a[i]!=str)
            {       
            //a[i]=str.split(",");
            //List l=(List)str.split(",");
            //a=str.split(",");
            for(int r=0;r<a[i];r++)
            FirefoxDriver fd=new FirefoxDriver();
            fd.get("https://login.yahoo.com/");
            fd.findElement(By.id("username")).sendKeys(a);
            Thread.sleep(2000);
            fd.findElement(By.id("passwd")).sendKeys(a);
            Thread.sleep(2000);
            fd.findElement(By.id("submit")).click();
            Thread.sleep(6000);
            try
            {
                if(fd.findElement(By.linkText("Hi, praveen")).isDisplayed())
                {
                    System.out.print("login success");
                }
            }
            catch(Exception e)
                {   
                //below line code is xpath copy
                str=fd.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div/div/fieldset/div")).getText();
                 //String str=fd.findElement(By.xpath("//[@class='lgbx-ltr']/fieldset/div")).getText();
                System.out.print("login failled"+str);
                //screen shot of dis page
                File f=fd.getScreenshotAs(OutputType.FILE);
                FileUtils.copyFile(f,new File("G:\\gpr\\selenium_pract\\yahoo"+a+".jpg"));
                }
            fd.close();
            }
Reply all
Reply to author
Forward
0 new messages