0

セレンideを使用して実行時に入力を取得したい。誰かが私を助けることができますか?

4

2 に答える 2

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

あなたのためのサンプルスクリプト

于 2012-07-13T05:27:37.417 に答える
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);

  }
}
于 2020-10-27T01:20:10.340 に答える