Search code examples
javaseleniumselenium-webdriverchrome-web-driver

Java - Selenium (chrome driver) element not visible exception


I have 2 websites that i would like to automate search process, and i am struggling of finding a way to locate and fill elements and speed up the process(as i use these websites many times a day): http://pretraga2.apr.gov.rs/ObjedinjenePretrage/Search/Search http://www.nbs.rs/internet/english/67/rir.html

I tried almost everything, and managed to locate the text field "Матични број:" on the first website, but when trying to fill it i get element not visible exception. The second site i tried triggering javascript but it opens the form for search in new window, and the search cant be made from there.

Hopefully someone will come up with some kind of solution, thanks in advance.


Solution

  • There are exactly two elements with same id and names. If you carefully investigate you will see the second element is the one you want.

    td.apr-mbr>[name='SearchByRegistryCodeString']
    

    Edit:

    This code works just fine on first link.

    WebElement element = driver.findElement(By.cssSelector("td.apr-mbr>[name='SearchByRegistryCodeString']"));
            element.sendKeys("Test");
    

    enter image description here