How to select value from the auto suggestion text box?

后端 未结 4 1124
刺人心
刺人心 2021-01-29 11:12

From text boxI have tried many methods to find out the solution but I failed, So please help me regarding this Query

Website:- https://www.goibibo.com/

Inside th

4条回答
  •  别那么骄傲
    2021-01-29 11:38

    You can use below code and instead of sending value hardcoded you can read it through Excel for dynamic.

    import java.awt.AWTException;
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.annotations.Test;
    
    public class Testing {
    	public static WebDriver driver;
    
    	@Test
    	public void test() throws InterruptedException, AWTException {
    		System.setProperty("webdriver.chrome.driver", "./Driver/chromedriver");
    		driver = new ChromeDriver();
    		driver.get("https://www.goibibo.com/");
    		driver.manage().window().maximize();
    		driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
    		WebElement fromDropDwon = driver.findElement(By.xpath("//input[@id='gosuggest_inputSrc']"));
    		fromDropDwon.click();
    		fromDropDwon.sendKeys("Delhi (DEL)");
    		fromDropDwon.sendKeys(Keys.ARROW_DOWN);
    		fromDropDwon.sendKeys(Keys.ENTER);
    		
    	}
    }

    Kindly upvote and it matches your expectation.

提交回复
热议问题