The mention program is Chegg login by using Java andSelenium. This is complete working program no error. Onlyadd some functionality:
i) Add the functionality of logout after successful login theaccount
ii)After logout exit the firefox browser that openthe Chegg site.
Note: I mentioned complete source codeand image of my Eclipse IDE.
Program:
package automationframework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class OpenChegg
{
public static String driverPath = “f:/”;
public static WebDriver driver;
public static void main(String[]args) throws InterruptedException {
System.out.println(“launching chrome browser”);
//System.setProperty(“webdriver.chrome.driver”,driverPath+”chromedriver.exe”);
//driver = new ChromeDriver();
System.setProperty(“webdriver.gecko.driver”,”c:/geckodriver.exe”);
WebDriver driver = new FirefoxDriver();
driver.navigate().to(“https://www.chegg.com/auth?action=login&reset_password=0”);
driver.findElement(By.xpath(“//*[@id[contains(.,’emailForSignIn’)]]”)).sendKeys(“abcdef@vfx.com”);
driver.findElement(By.xpath(“//*[@id[contains(.,’passwordForSignIn’)]]”)).sendKeys(“defgh”);
driver.findElement(By.xpath(“//button[text()=’Signin’]”)).click();
//WebElement e = driver.findElement(By.xpath(“//*[text()=’sarikajain’]”));
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
System.out.println(“wait to respond………”);
Thread.sleep(10);
List<WebElement> list =driver.findElements(By.xpath(“//*[contains(text(),'” + “Email andpassword do not match.”
PayPal Gateway not configured
PayPal Gateway not configured