1

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.

2
  • How are you identifying the element? Probably the selector you are using is incorrect Commented Sep 20, 2015 at 21:58
  • Welcome to Stack Overflow! Please read the guide How do I ask a good question, especially the part on Minimal, Complete, and Verifiable example (MCVE). This will help you solve problems for yourself. If you do this and are still stuck you can come back and post your MCVE, what you tried, and what the results were so we can better help you. Commented Sep 20, 2015 at 23:03

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for the answer, i have located it but when i try to send keys to it it gives me the element not visible exception.. I can post the code i used... edit: List<WebElement> frameList=driver.findElements(By.className("SearchTable")); WebElement a = frameList.get(1); List<WebElement> st1=a.findElements(By.className("apr-mbr")); WebElement test11 = st1.get(1); WebElement testuno = test11.findElement(By.xpath("//input")); System.out.println(testuno.getAttribute("id")); and the id matches the one i inspect, but still cant acess the box..
@b02 You are doing too much unnecessary work. See my edit
Thanks a bunch mate, you made it so easy, i guess i need to look up into css selectors and xpaths a bit more, makes it a lot easier than what i used :) should i use similar solution to the second website ?
What are looking for in second website?
To fill registration number text field and hit Search button.. But this one has javascript that loads the form, i tried executing it but it opens useless form in new window.
|
0

this can also happen occasionally when the element is not visible without scrolling (but I don't know exactly why although the element in my case not is hidden) I found the solution is to move the focus to the element before call the action required (click,sendKeys, etc)

Actions actions = new Actions(driver);
actions.moveToElement(webElement).perform();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.