WebElement myElement = driver.findElement(By.cssSelector(usernameSelectorPath));
usernameSelectorPath is a String variable which I have created in the fields, and I am having the user of the program enter the selector of the username box and store that as usernameSelectorPath. However, when I take that usernameSelectorPath to convert it to a WebElement, I get a java.lang.NullPointerException and I am unable to do it. I think it is because the variable type is a string, and it is a reference variable.
How can I fix this problem and convert String to a WebElement?