1

Can anybody explain why it is works in this way? I have a simple test and it works with Chrome and Firefox perfect on Windows 10.

    public class MyFirstTest {
    private WebDriver driver;
    private WebDriverWait wait;

    @Before
    public void start() {
        //driver = new InternetExplorerDriver();
        driver = new ChromeDriver();
        //driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        wait = new WebDriverWait(driver, 40);
    }

    @Test
    public void myFirstTest() {
        driver.get("http://www.google.com/");
        driver.findElement(By.name("q")).sendKeys("web");
        driver.findElement(By.name("q")).sendKeys(Keys.ESCAPE);
        driver.findElement(By.name("btnK")).click();

        //WebElement el = driver.findElement(By.name("btnK"));
        //JavascriptExecutor executor = (JavascriptExecutor)driver;
        //executor.executeScript("arguments[0].click();", el);
        wait.until(titleIs("web - Поиск в Google"));
    }

    @After
    public void stop() {
        driver.quit();
        driver = null;
    }
    }

And only with Internet Explorer 11 it can interact with button and click it only using JavascriptExecutor (the piece of code commented). In other way there is "org.openqa.selenium.ElementNotInteractableException: Element is not displayed" is thrown and test failed.

hdanske
  • 21
  • 1
  • 5
  • I suggest you also post the HTML code of that button and it can be better if you post the HTML surrounded to that button. We can make a test on our end to check the result. You can visit the thread linked by @DebanjanB to know the possible causes and solutions for this issue. – Deepak-MSFT Mar 16 '20 at 03:24
  • I found the solution for my issue there before. I took the part with JavascriptExecutor from there. But it is a simple "google.com" page and selenium perfectly interact with button found by it's name attribute in two browsers from three. May be i need to set something. – hdanske Mar 16 '20 at 17:31
  • Did you try to find the button using any other properties of a button-like class name or anything else? As we don't have the actual code, it can be difficult for providing suggestions for it. – Deepak-MSFT Mar 17 '20 at 02:40
  • Yes, i did. I tried to find it by it's xpath and classname. The result was the same. The actual code i wrote above. It is exactly as i wrote there. – hdanske Mar 17 '20 at 13:02
  • Is it possible for you to post the relevant HTML? We don't need any confidential information. You can replace it with dummy text. It is required because we are not able to produce the issue without it. Thanks for your understanding. – Deepak-MSFT Mar 18 '20 at 09:40
  • It's really "www.google.com" page. And it is really button with name attribute "btnK" on the page. Nothing special. – hdanske Mar 18 '20 at 17:00
  • Here is my testing result with the Google page. You can see that code is clicking the button without any issue. https://imgur.com/a/gdUoYrk – Deepak-MSFT Mar 19 '20 at 07:20

0 Answers0