0

Below is the code I tried for highlight the elements in website when executing my code, but highlight is not happening for me.

My Helper class in Utility package:

public class Helper {

    WebDriver driver;

    public Helper(WebDriver driver){
        this.driver=driver;
    }

    public void highLightElement(WebDriver driver,WebElement element){

        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("arguments[0].style.border='3px solid red'", element);
        try{
            Thread.sleep(500);
        }
        catch(InterruptedException e){
            System.out.println(e.getMessage());
        }
    }
}

LoginPage.java:

public class LoginPage {

    WebDriver driver;
//public Helper helper=new Helper(driver);

    WebElement Agentid=driver.findElement(By.xpath(".//*[@id='admin_value']/div[1]/input"));
    WebElement agentEmailid=driver.findElement(By.xpath(".//*[@id='admin_value']/div[2]/input"));
    WebElement agentPwd=driver.findElement(By.xpath(".//*[@id='admin_value']/div[3]/input"));
    WebElement loginbtn=driver.findElement(By.xpath(".//*[@id='admin_value']/input"));

    public LoginPage(WebDriver driver){
        this.driver=driver;
    }

    public void AgentLogin(String agentid,String agent_emailid,String password){
        Helper helper=new Helper(driver);
        helper.highLightElement(driver, Agentid);
        Agentid.sendKeys(agentid);
        helper.highLightElement(driver, agentEmailid);
        agentEmailid.sendKeys(agent_emailid);
        helper.highLightElement(driver, agentPwd);
        agentPwd.sendKeys(password);
        helper.highLightElement(driver, loginbtn);
        loginbtn.click();       
    }
}

LoginPageActions.java:

public class LoginPageActions {

    WebDriver driver;   
    /*public LoginPageActions(WebDriver driver){
        this.driver=driver;
    }*/ 

    @BeforeClass
    public void startup(){
        System.setProperty("webdriver.gecko.driver","D://Krishna//geckodriver-v0.11.1-win32//geckodriver.exe");
        System.setProperty("webdriver.chrome.driver", "D://Krishna//chromedriver_win32//chromedriver.exe");
            driver=new ChromeDriver();
            driver.navigate().to("http://************");
            driver.manage().window().maximize();

    }

    @Test(priority=1)
    public void Login(){        
        LoginPage login=new LoginPage(driver);      
        login.AgentLogin("100", "krishna@yahoo.com", "abc");        
        HomePage home=new HomePage(driver);
        home.click_SignOut();
    }

Output:

FAILED: Login

===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================

Showing Error as -java.lang.NullPointerException

Krishna
  • 21
  • 1
  • 6
  • Where is the "java.lang.NullPointerException" appearing - is that in your output, or somewhere else? What line is it pointing to? – halfer Jan 30 '17 at 13:30
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – TimeToCode Jan 30 '17 at 14:16
  • Hi halfer, In output i am getting this "java.lang.NullPointerException". Is there any problem with assigning type as WebElement for locators? – Krishna Jan 31 '17 at 05:47

0 Answers0