1

I'm just trying to find out how to tell java to open a website and enter text (preferably a string value) into a text field

For example go to Google and search any text( it does not have to be user entered)

I realize that it wont actually open any browser or print anything from a website. I just need to know this basic part to build on for my program.

anthoK
  • 31
  • 1
  • 3
  • Do you want the browser to _actually_ open and have a bot type it in for you, like [Selenium](http://docs.seleniumhq.org/), or are you just trying to send a GET request to Google's webservice(s)? – Justin Jasmann Mar 06 '14 at 01:46
  • Im trying to have the program go on a website and enter text into a text field, that's all for now. I was looking into Selenium, but I wasn't sure that's what i wanted. – anthoK Mar 06 '14 at 01:54

2 Answers2

0

If you try to query to Google in your example and want to get the search result, you can use query string and read its html result

Wins
  • 3,420
  • 4
  • 36
  • 70
0

Figured it out . I had to use a combination of Selenium and HtmlUnit. My code is something like this

WebDriver driver = new HtmlUnitDriver();

driver.get("https://www.google.com");

WebElement element = driver.findElement(By.name("q"));

element.sendKeys("Hello");


driver.quit();
anthoK
  • 31
  • 1
  • 3