How to locate and type something in the textbox

后端 未结 4 2028
旧巷少年郎
旧巷少年郎 2020-12-12 06:03
public class testFluent {   

WebDriver driver;   
    @Before
        public void setUp(){        
    driver = new FirefoxDriver();
    driver.manage().window().ma         


        
4条回答
  •  庸人自扰
    2020-12-12 06:49

    I hope this helps u..

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;  
    
    
    public class yahoo {  
    
         FirefoxDriver Driver=null;
         WebDriverWait wait = null;
    
    
    
         @BeforeTest  
         public void start(){  
          Driver = new FirefoxDriver();  
         }  
    
        @Test 
         public void Test() throws InterruptedException{   
          wait=new WebDriverWait(Driver,90); 
          System.out.println("Loading yahoo search page");  
          Driver.get("http://www.yahoo.com");  
          System.out.println("Yahoo search page loaded fine");  
          WebElement text=wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='p_13838465-p']")));
          text.sendKeys("selenium");
          Thread.sleep(5000);
    
         }  
    
         @AfterTest  
         public void close(){  
         Driver.quit();   
         }  
        }  
    

提交回复
热议问题