Thursday, August 20, 2015

How to login into any site if its showing any authentication popup for user name and pass ?

How to login into any site if its showing any authentication pop-up for user name and pass ?
Ans - pass the username and password with url.
Syntax- http://username:password@url
ex- http://creyate:jamesbond007@alpha.creyate.com

3 comments:

  1. What if there are two authenticatio.
    Means username1 pwd1 and then username2 and pwd2.
    Please guide

    ReplyDelete
  2. Hi Sanjay,

    I am getting the below exception while clicking on build now option from jenkins

    Exception:

    Started by user anonymous
    Building in workspace E:\Jenkins\Jenkins_Demo
    [Jenkins_Demo] $ cmd /c call C:\Windows\TEMP\hudson3659900997792223027.bat

    E:\Jenkins\Jenkins_Demo>run.bat

    E:\Jenkins\Jenkins_Demo>java -cp bin;lib/* org.testng.TestNG testng.xml
    java.lang.UnsupportedClassVersionError: org/testng/TestNG : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main" Build step 'Execute Windows batch command' marked build as failure
    Finished: FAILURE

    I have created one batch file with name 'run.bat' which has below command

    java -cp bin;lib/* org.testng.TestNG testng.xml

    script which is written in eclipse ide :

    package com.sample.jenkins;

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.annotations.Test;

    public class Jenkins_Demo
    {
    @Test
    public void jenkinsdemo()
    {
    System.setProperty("webdriver.chrome.driver","E:\\dirvers\\chromedriver.exe");
    WebDriver driver=new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.google.com");
    System.out.println("jenkins demo added kusuma");

    }
    }


    above script was executed succesfully when this command(java -cp bin;lib/* org.testng.TestNG testng.xml
    ) is being executed from cmd prompt.But while clicking on build now option in jenkins facing the problem

    ReplyDelete
  3. Hi Sanjay

    I want to execute login to a URL with multiple users at the same time on the same browser, can u please let me know how can i achieve this using multi thread.

    ReplyDelete