MarkusBernhardt / robotframework-selenium2library-java

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework
Apache License 2.0
46 stars 48 forks source link

Switch window Issue #71

Closed sunil31925 closed 9 years ago

sunil31925 commented 9 years ago

I try all three way called select window by url, name and title but getting same error. my xpath is correct i also verify that. here is my sample code ################### Clicking below link open new window Click Link xpath=//div/a[contains(text(),'Browse')]

Capture Page Screenshot
${window_names}=    Get Window Names
${main_window_name}=   Get From List   ${window_names}  0
${child_window_name}=   Get From List   ${window_names}  1
#${child_window_url}=   Switch To Window    ${child_window_name}
Select Window   name=${child_window_name}   
  ################### Below screen shot also give child window screen shot
Capture Page Screenshot
    ################### below line give an error 

Create Equipment IO | FAIL | Element 'xpath=//a[text()='Planned Devices']' did not appear in 5 seconds Wait Until Page Contains Element xpath=//a[text()='Planned Devices']

asitishere commented 9 years ago

Hi Sunil,

Even I found the problem in Switch window so I have added an extra Keyword in Browser library which will support such scenario. Even switch to Frame was not Fluent .

You can implement using multiple ways , below is one example where you can switch to another window by Page Title ( You can apply any other content Logic):

@RobotKeyword
@ArgumentNames({"windowsTitle"})
public void changeFocusToWindow(String windowsTitle) throws InterruptedException {

            WebDriver driver = getCurrentWebDriver();
    Set<String> windowsHandle = getWindowsHandler();
    logging.info("Count of open Windows by WebDriver Instance "+windowsHandle.size());
    for (String sHandler : windowsHandle) {

        if (driver.switchTo().window(sHandler).getTitle().contains(windowsTitle)) {
            //windowHandleDriver=driver.switchTo().window(sHandler);
            logging.info("After Window context Switch the current working Window Page title is " + driver.getTitle());
            break;
        }
    }
}

Let me know if any issue.

asitishere commented 9 years ago

@sunil31925

You can copy the code and try. The above code works for me as the driver instance is single and we are switching between the windows.

Try and let know .

sunil31925 commented 9 years ago

Ok, now it's work for me. Thanks you so much

Sent from my iPhone

On Jul 26, 2015, at 6:35 PM, Asit notifications@github.com wrote:

@sunil31925

You can copy the code and try. The above code works for me as the driver instance is single and we are switching between the windows.

Try and let know .

— Reply to this email directly or view it on GitHub.

asitishere commented 9 years ago

No worries Sunil.

Which company you work for and are you liking the Robot Framework ?

sunil31925 commented 9 years ago

Trail demo going on let see how's thing going

Sent from my iPhone

On Jul 28, 2015, at 6:52 PM, Asit notifications@github.com wrote:

No worries Sunil.

Which company you work for and are you liking the Robot Framework ?

— Reply to this email directly or view it on GitHub.

asitishere commented 9 years ago

Its simple and useful if manual testing team use the Robot Default or user generated keywords to convert test cases to Robot Test cases steps. But if that's not the case and for a complex project and application under test is complex where you have AJAX and FRAMES, multiple windows then you have to think.

I started using from few months but I like to code in Java rather call the keywords . Good if you implement EventfiringwebDriver top of the default WebDriver and work on that. This way beforeElement click you can add a common selenium EXPECTEDCONDTION.

Good luck

Cheers Asit