如何在selenium IDE中提供运行时输入?

时间:2012-07-13 05:07:58

标签: selenium-ide

我想在运行时使用selenium ide获取输入。任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:6)

您可以添加break命令或input-box

1.By input-box
Command 1
Command 2
Command 3
4th command will be
storeEval | prompt(“Enter input”); |variable
type | locator of field where you want to put value| ${variable}
continue with your next commands

2.By break command

Command 1
Command 2
Command 3
4th command will be
Break
Enter input manually and resume execution of test
continue with your next commands

Sample Script for you

答案 1 :(得分:0)

您可以在运行时使用java.util.scanner输入用户输入。

import java.util.Scanner;

public class UserInputExample(){
  Scanner inputText = new Scanner(System.in);
  public static void main(String[] args ){
    String search= inputText.next();
 driver.findElement(By.xpath("//body/div[@id='searchform']/form[@id='tsf']/div[2]/div[1]/div[2]/div[1]/div[2]/input[1]")).clear().sendKeys(search);

  }
}
相关问题