Re: [selenium-users] Selenium Webdriver is unable to locate any element in a popup page

3,175 views
Skip to first unread message

Rajesh Ratakonda

unread,
Apr 5, 2013, 9:28:37 AM4/5/13
to seleniu...@googlegroups.com
What is the count of the available windows? Is popup window title available in the available windows set? Can you pass the controls to popup?? After you switch to popup window try to click in the text box and then see if it can recognize the xpath or not.

try this code for clicking the go button

popup.findElement(By.xpath("//input[@value='Go!']"));

I am not sure of '!'. try removing it if it is not working.

Rajesh.
 


On Fri, Apr 5, 2013 at 12:18 AM, sourav mukherjee <mail2s...@gmail.com> wrote:
 Hi All,
            I am getting following error message while trying to click on an element in a popup page. The details are provided below.

Error: Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//input[@id='lksrch']"}

Attachments:
    1. Contains the screen shot of the application.
    2. Another attachment to show the firepath xpath.

Information: Web Driver is able to locate all the objects in the parent window. And using my below mentioned code Web driver is able to recognize the popup window. But it is not locating any of the element in the popup screen using the xpath. I have tried with many combination to frame the xpath of the Go button. But it never worked at all. I don't have much knowledge on framing the xpath. Can you please suggest what could be the possible mistake I am doing. Is it in the xpath or something else. 


The java code i am using to click on Go button in the popup page is:

public static WebDriver myWD,popup;
String  xpath_gobutton;

xpath_gobutton = ".//*[@title='Go!']";
String currentWindow = myWD.getWindowHandle();
myWD.findElement(By.xpath(xpath_newCampaignLookup)).click();
Thread.sleep(4000L);
Set<String> availableWindows = myWD.getWindowHandles();
    if (!availableWindows.isEmpty()) {
            for (String windowId : availableWindows) {
                    if (count == 1){
                            System.out.println("Success");
                            System.out.println("all windows: " +windowId);
                            System.out.println("The title of the window is: "+myWD.switchTo().window(windowId).getTitle());
                            popup = myWD.switchTo().window(windowId);
                            popup.findElement(By.xpath(xpath_gobutton)).click();
                            break;
                    } else {
                            count = count + 1;
                             }
               }

Thanks and Regards,
Sourav Mukherjee

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/USrHjysfBD4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sourav mukherjee

unread,
Apr 8, 2013, 1:41:53 AM4/8/13
to seleniu...@googlegroups.com
The available window are two. Webdriver is able to locate both the window. Because I am printing the title of both the window and it is printing correctly. But whenever I am trying to click any element(Edit box, link, button) in that page. It is throwing '.NoSuchElementException' error. 

Yes. I am able to Pass the control to popup.After I switch to popup window I tried to click on text box using the xpath. But it is throwing same error. I can ensure you it is nothing to do with 'exclamatory symbol (!).'

Thanks,
Sourav 

Ripon Al Wasim

unread,
Apr 8, 2013, 3:48:48 AM4/8/13
to seleniu...@googlegroups.com
It needs to switch to pop up window as below:

driver.switchTo().alert();

Ripon
Reply all
Reply to author
Forward
0 new messages