Reputation: 896
I am absolutly new in selenium so sorry for the noob question. But i couldnt find it in google. So, I have a simple javacode :
public static void main(String[] args) throws Exception {
// The Firefox driver supports javascript
WebDriver driver = new FirefoxDriver();
// Go to the Google Suggest home page
driver.get("http://tudakozo.telekom.hu/main?xml=main&xsl=main");
// Enter the query string "Cheese"
WebElement query = driver.findElement(By.xpath("id('searchByName')/x:input[2]"));
the webpage btw : [link][1] I want to fill the left boxes. To do so I want some selenium commands : s.fill(and here xpath, "fill with text")
For xpath i use firefox plugin and find xpath: i cant post image so heres a link : http://tinypic.com/view.php?pic=5poglt&s=8#.U_sw-vl_tVY
Then I will get somecapthca breaker Its in the local future but if oyu have suggestion i take it :) Anyway than i need to download the pics and manually fill it. Than click the "keresés" button xpoath: id('searchByName')/x:input[2] but in the first step i fail, and i cant check that is the seleinum (JAVA) filled the field?
** So the main question how can i fill the fields, download a pics through xpath in selenium (JAVA), than save the output**
example : *név*(name) :first field : **Szabó István** and
*Település*(city)/the field where there is a little pink text/ : **Gyula**
Upvotes: 1
Views: 1247
Reputation: 12410
You can use Selenium and Java to save an image like so,
string url = "yourimage.png";
BufferedImage bufImgOne = ImageIO.read(url);
ImageIO.write(bufImgOne, "png", new File("test.png"));
As far as filling out a form,
driver.findElement(By.id("yourID")).sendKeys("text you need to send");
If you're looking to get the image src from an xpath to download that src do this,
WebElement img = driver.findElement(By.id("foo")); // or xpath whichever you prefer
String src = img.getAttribute("src");
Upvotes: 2