Selenium WebDriver, work without an internet browser.
I have a simple selenium class. it works really well. Now I'm wondering how to do the same in console mode. In other words. I want the result (in code if the request was successful or not). I don't need to show in a web browser. if all is well, I need to return a value, if not another return value (something like true or false);
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
WebDriver driver;
WebElement loginInput;
WebElement passwordInput;
WebElement loginSubmit;
driver = new FirefoxDriver();
driver.get("URL");
loginInput = driver.findElement(By.id("id"));
loginInput.sendKeys("ninotyesh");
passwordInput =driver.findElement(By.id("id"));
passwordInput.sendKeys("key");
loginSubmit = driver.findElement(By.id("id"));
loginSubmit.click();
+3
user1454686
source
to share
1 answer
You can use the script in HTMLUnitDriver
- see short help on this
And at the end of your code, I would check some element that should be present after successful login and print TRUE in case the driver finds it.
+5
source to share