Error in notifications | Selenium Forum
R
Rupa Posted on 18/06/2020
Here is my code, by using disable notifications it works for some time and it was not working. i was unable to search required thing. package section13; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class Demo { public static void main(String[] args) throws Exception { ChromeOptions options=new ChromeOptions(); options.addArguments("--disable-notifications"); WebDriver driver=new ChromeDriver(options); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.get("https://www.makemytrip.com/"); System.out.println(driver.getTitle()); //clicking on buses WebDriverWait wait=new WebDriverWait(driver,20); wait.until(ExpectedConditions.visibilityOfAllElements(driver.findElement(By.xpath("//div[@class='chHeaderContainer']/nav/ul/li[6]")))); driver.findElement(By.xpath("//div[@class='chHeaderContainer']/nav/ul/li[6]")).click(); Thread.sleep(2000); driver.findElement(By.xpath("//div[@class='bussw_inputBox selectHtlCity '][1]")).click(); driver.findElement(By.xpath("//input[@placeholder='From']")).sendKeys("Bang"); driver.findElement(By.xpath("//input[@placeholder='From']")).sendKeys(Keys.DOWN); driver.findElement(By.xpath("//input[@placeholder='From']")).sendKeys(Keys.DOWN); driver.findElement(By.xpath("//input[@placeholder='From']")).sendKeys(Keys.DOWN); System.out.println(driver.findElement(By.xpath("//input[@placeholder='From']")).getText()); JavascriptExecutor js=(JavascriptExecutor)driver; String script="return document.getElementById('//input[@placeholder='From']').value;"; String text=(String) js.executeScript(script); System.out.println(text);

A
Ashish Thakur Replied on 23/06/2020

Your code is all jumbled up

attach the java file

also... plz attach error screenshot