-3
public WebElement locater(String locter)
    {
        String[] value = locter.split("##");
        String loctValue = value[0];
        String loctType = value[1];



        try {
            if(loctType.equalsIgnoreCase("XP"))
            {


                loct = driver.findElement(By.xpath(loctValue));


            }
            else if(loctType.endsWith("id"))
            {
                loct = driver.findElement(By.id(loctValue));

            }
            else if(loctType.equalsIgnoreCase("linkText"))
            {
                loct = driver.findElement(By.linkText(loctValue));
            }
            else if(loctType.equalsIgnoreCase("partialLink"))
            {
                loct = driver.findElement(By.partialLinkText(loctValue));
            }
            else if(loctType.equalsIgnoreCase("cssSelect"))
            {
                loct = driver.findElement(By.cssSelector(loctValue));
            }
            else if(loctType.equalsIgnoreCase("name"))
            {
                loct = driver.findElement(By.name(loctValue));
            }
            else if(loctType.equalsIgnoreCase("tagname"))
            {
                loct = driver.findElement(By.tagName(loctValue));
            }

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
        return loct;

    }

Unable to resolve...any one can help me out

Stultuske
  • 9,296
  • 1
  • 25
  • 37

1 Answers1

0

Please check for loctType, loctValue is not null. And also its good to check locter too is not null before your try catch operation.

Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112
Sirsendu
  • 283
  • 1
  • 8