Advertisement
piffy

seleniumtest

Nov 3rd, 2021
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {By,Key,Builder} = require("selenium-webdriver");
  2. require("chromedriver");
  3.  
  4.  
  5.  
  6. async function ricerca(){
  7.  
  8.  
  9.        var searchString = "Automation testing with Selenium";
  10.  
  11.        //Lanciare il browser
  12.        let driver = await new Builder().forBrowser("chrome").build();
  13.  
  14.         //Visualizzare https://duckduckgo.com/
  15.         await driver.get("https://duckduckgo.com/");
  16.            
  17.         //inserire la nostra stringa di ricerca
  18.         await driver.findElement(By.name("q")).sendKeys(searchString,Key.RETURN);
  19.  
  20.         //Recuperiamo il titolo e stampiamolo
  21.         var title = await driver.getTitle();
  22.         console.log('Il titolo è:',title);
  23.  
  24.         //Buona abitudine
  25.         await driver.quit();
  26.  
  27. }
  28.  
  29. ricerca()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement