简体   繁体   中英

How to put selenium webdriver within a Java Applet

I am using selenium to automate some tasks and attempted this with python but had no luck. From what I have been reading Java is the best way to go. I am trying to automate some tasks for myself. i want to fill out and submit forms using selenium. The form has 10 fields. All fields are automated with selenium except for 3 which i fill out. my problem is, I am able to completely fill out the fields and submit the form using java but I can't figure how to fill in the 3 fields by me (currently i open the selenium java in eclipse, change the 3 fields, compile and then run, need to do this with each new submission).

I want to create a JApplet form and enter the 3 fields, then that would put it into selenium java and submit it. I have searched all over and cant find any way to complete this task.

Clarification

**My Current Setup**
Selenium in Java (using eclipse)
Task 1:
- Fields 1 - 7 prefilled and never change.
- I change:
  - WebElement element = driver.findElement(By.name("Type")); element.sendKeys("XXX");
  - WebElement element = driver.findElement(By.name("ID")); element.sendKeys("XXX")
  - WebElement element = driver.findElement(By.name("Manu")); element.sendKeys("XXX");
- Compile and Run
- Selenium goes to website using driver.get("http://www.example.com");
- fills 1 - 10 and hits submit.

Task 2:
- Fields 1 - 7 prefilled and never change.
- I go back into eclipse and change:
  - WebElement element = driver.findElement(By.name("Type")); element.sendKeys("YYY");
  - WebElement element = driver.findElement(By.name("ID")); element.sendKeys("YYY")
  - WebElement element = driver.findElement(By.name("Manu")); element.sendKeys("YYY");
- Compile and Run
- Selenium goes to website using driver.get("http://www.example.com");
- fills 1 - 10 and hits submit.

etc....

I want to make it so I dont have go back each time and change the fields above for each new task. I want to have a web form on a web page have these three fields.

I want:
Task 1
MySite -> FORM with textbox: Type, ID, Manu -> Submit -> fills into the XXX above -> run Selenium
Task 2
MySite -> FORM with textbox: Type, ID, Manu -> Submit -> fills into the YYY above -> run Selenium

hope this makes sense

I am very confused by your explanation. In your comment you stated "I want a webpage that has Type, ID, Manu in a Text field then when I hit submit it puts those in selenium". That is not the way Selenium works. Selenium can be used to take actions on your web page - the same way that a human user would interact with the web page. You don't "put things into Selenium" from your web page. It's the other way around. Selenium interacts with your web page, clicking buttons, clicking links, typing text, etc. Please clarify your question and post an example of what you are trying to do if necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM