How to pass control to a new window(not popup) in selenium? - selenium

My site has a link which navigate to another site. I have to check whether the link taking the user to correct website. The following is the code i've written to pass control
selenium.click("link=target window");
selenium.selectWindow("Title of target window");
assertTrue((selenium.isTextPresent("content in target window")));
selenium.close();
selenium.selectWindow("null");
But if i run this i'm getting error like "Could not find window with title ... "

There is information about how the selectWindow() function locates the window here. In particular,
If you're having trouble figuring out what is the name of a window
that you want to manipulate, look at the selenium log messages which
identify the names of windows created via window.open (and therefore
intercepted by selenium). You will see messages like the following for
each window as it is opened:
debug: window.open call intercepted;
window ID (which you can use with selectWindow()) is "myNewWindow"

Related

TestCafe window.sessionStorage.getItem() returns null

Our application use browser session storage to store information which will be read by child window.
There is example scenario:
User clicks on link to open child window. New window is opened with window.open() and then we store information in child's session storage. When child window is loaded it will get information from session storage.
Problem:
When child window trying get value from session storage (with: window.sessionStorage.getItem('my_key')) it returns null and because of this application doesn't work properly when run in TestCafe and tests are failing.
In chrome dev tools I can see that session storage has this value. I printed to console what is under window.sessionStorage and it returns Proxy object (see screenshot):
I checked and key provided to window.sessionStorage.getItem is correct and also I noticed that under 'internal -> nativeStorage' is my value that I'm looking for (is not visible on screenshot because I can't show this data).
I don't know if it is a bug or I just need configure something but I didn't find information about it in google.
Is it possible to make TestCafe works as expected in this scenario? If yes, how?
It happens because TestCafe can't open a page in a new tab in the same window and opening a page in a new window creates a new session Storage. To work around this you can use disableMultipleWindows.

Selenium : After clicking a Click in home page , one more screen appears and it got altogether different new DOM loaded

Selenium : After clicking a Click in home page , one more screen appears and it got altogether different new DOM loaded and am currently unable to handle any elements using selenium and getting Element not found exception
Note : Tried Manually to load the same page and in browser console provided the same element and got nothing . but after long time it shows element. Is there a way to handle it?
You can handle your child window using below code. Basically we need to switch web driver control from your parent window to child window and once you finish process then again you have to switch control back to your parent window for further process. We can use window_handles to get handle of all opened windows by web driver and then we can switch from one window to another in a web application
Different Windows
Python :
driver.switch_to_window(driver.window_handles[-1])
title=driver.title
To handle synchronisation issue you can always use different types of waits available in the selenium e.g: implicit, explicit etc.

How to check xpath element exist in webpage using workfusion studio?

Check xpath element exist in opened webpage using workfusion studio conditional action.
Currently i'm using webelement Actions Library to login on specific website. its working fine.
But when i already logined then its give me an error on login steps because its redirected on home page directly.
So, I want to check if Xpath element is exist on my webpage or not.
To accomplish a check, you can create an Exception Handling block, and put a Mouse Click by this XPath inside the "Try to completeā€ block.
Alternatively, you can use the Retry block or add more Wait time

Does selenium / webdriver with protractor wait for async activity in a describe block before continuing?

I have code in a desribe block but some of my set up code is outside of the block. That's the code that sets up elements.
When my code executes it runs fine but then I see the browser go to another page before parts of my test have completed. With a different page on the browser then it looks for elements and throws an exception when they are not there.
So how can I handle this problem of the browser going to another page before tests are completed?
As per my understanding of the question you want to be on the same page and don't want to move to the new page which loads when you click on to a link/button. If this is the case then to be on the same page you cane use.
Use this command -String oldwindow=window.getWindowHandle();
window.switchTo().window(oldwindow);
Use this command just below the button code which throws a new window. I am a java programer thats why the code written is in java.
getWindowHandle Methods stores the url of current window in oldwindow string and by using window.switchTo().window(oldwindow) it won't move to new window because you are passing oldwindow as argument for the command.
For more go through the Webdriver documentation by clicking this link

How to call chrome function from browser content page in xulrunner

I am converting code that originally ran as remote signed jar files in Firefox to use XULRunner instead. There are several reports that are implemented as web pages with an output option. Options include an HTML page or a report viewer that is written in XUL and Javascript.
When the user submits the form, and the report viewer is selected, then I need to open a chrome window. Obviously this cannot be done directly for security reasons. I want to provide a function or use some sort of message passing method to signal to the containing chrome what needs to happen.
Can this be done and if so how? Things I am considering:
1) Adding a function to the content window's window or document object
2) Some sort of message passing function
3) Some sort of customer event send/receive
4) A special URL form with a handler such as repviewer://repname/parameters
There is a quite elaborate article on this topic on MDN. The best way to achieve this without jeopardizing security is to send a generic event from your web page. The top XUL document should call addEventListener() with the fourth parameter set to true which will allow it to receive such untrusted events. Data can be passed through an attribute of the event target, the XUL document can then inspect that attribute.