Problem with Pop-up Windows using Selenium - windows

I'm new to the testing world, so my question might seem a lil' bit too naive and stupid. At risk of looking/sounding stupid, my question is this:
I've been trying to test the contents in a pop-up window on my company's web app. I've figured out how to detect the pop-up window for now, but i can't get selenium to 'click' on the link inside of that pop-up window. there are multiple pop-ups in this web app so it's really difficult for a newbie like to create a test case.
I tried the click, clickAndWait, mouseDown and mouseKey as an option but it is still not working. can somebody guide me through this?
TIA,
Angela

When the popup appears you will need to move the context of the script over to the window.
You can do this by using the selectWindow | window_ID_from_the_link and then do the clicking.
If that doesn't work you may need to use the openWindow command to create the popup and then start testing against that.

Use getConfirmation/getassert/getprompt according to the type of the pop up you use .....By default they will be clicked with ok option by the server and you have to consume the message from the pop up for the other selenium commands to work correctly.............
The above suggestion is given from my experience in working with selenium RC used with perl..........

Perhaps you can try the FireFox Plugin. You can click through your application and record your steps. After recording the steps you can easily save it as some sort of file or unittest.
I'm not sure about the command you should use for the popups, maybe the firefox plugin will help in this manner (it will create your commands).

If you created the popup with a div tag, U can use following code to stop the selenium server until the popup opens.
int second = 0;
while(!selenium.IsElementPresent(mylink))
{
if(second >= 5)
break;
Thread.Sleep(1000);
second++;
}
After a popup opens, Now you can click on any link inside the popup.You have to use the below code.
selenium.click("id=popup_link"); (popup_link is the id of the link present on the popup)
Good Luck.

Not sure if this is what you are looking for, but if you want to click on something specific that Selenium is not able to handle - like browser pop-ups or other pop-ups, you can use Sikuli Script. Sikuli does an image comparison and clicks on the same - this is very powerful.
Here is the link: http://www.sikuli.org/

Related

Selectors only work when webpage is opened in Internet Explorer

I created a login sequence and my selectors for the input email, password, click login and element exists are valid. But only when I have the Internet Explorer page open on the website I'm working with.
I did that sequence again, and I ran it, initially it worked but when I ran the hole project it broke again, I tried "repair" and "indicate", I tried to eliminate the title but nothing is working.
As far as I can see, you are using selector attribute:
"title=ACME System 1 - Dashboard"
Try using a wildcard: title='ACME System 1*', so it can work when you leave the dashboard.
This worked for me when I took those UiPath Academy courses.
In order to automate tasks within a browser with UiPath, the browser must be open. There is an activity called Open Browser that's included in the default activities for every project. You need to add this activity to the beginning of your sequence and pass in the appropriate parameters, (ie. URL, browser type) you can then pass the outputted browser variable to an attach browser sequence and execute your browser automation acivities within that.
Browser activity sceenshot
In addition, the selector that you have shared does not look like a stable selector. There may be other 'H1' elements on the screen that will cause your automation to fail. I would use the UI explorer to help you build a better, more stable selector.
Did you initially use IE to indicate screen elements and then changed the BrowserType property to use a different browser? Please share the sequence to suggest you a fix for your issue.
I would also suggest you to modify the selector to 'title='ACME System *'.
In order for selector to work the application needs to be open and the desired element needs to be available. So when you close the browser the selector disappears.
You may consider swithching to 'Modern Design Experience' and use 'Use Application/Browser' scope to make this more intuitive, and it will also automatically open the browser for you if it is closed.

cypress how to close the new window and back to main test window

I have written codes to click on hyperlink then check the new window URL.
cy.get('a[href*="newlink"]').eq(0).click()
cy.url().should('equal', 'https://www.google.com')
how do i close this window / or not close AND back to the original main test window?
here's a solution i use for swapping between popup windows: https://github.com/jakedowns/CypressHelpers
it would need some tweaking to work directly with .click
but it does enable cy.openWindow and a new cy.switchWindow / cy.closeWindow
under the hood it uses an undocumented
cy.state('document') and cy.state('window') method for context-switching
cy.go(direction, options)
See the documentation for examples
This works for the history in the same tab. Cypress does not support multiple tabs.
you can use cy.go('back')
see here

Selenium IDE - Wait for pop up right place

I run a Selenium IDE test on a website where lots of pop-up appear to explain the website. The process is
Popup (with same id) appears with specific text
Pop up move to the right place to explain an icon or another part of the website
Problem is that the "move to the right place" takes time. So my selenium IDE test continues without waiting. Then pop up conflicts appears and my test failed.
I can force it to "Pause" but this is not a clean solution. Does Selenium IDE have something like "WaitNoAjaxActionOnThePage"
I try "WaitForElementPresent" or "WaitSpecificText" but it does not resolve the problem with the previous logic.
Well I hope its clear,
Thanks a lot
Selenium IDE is not enough powerfull to deal with ajax ou CK editor. So I move to Selenium driver. There are more possibilities.
http://www.seleniumhq.org/projects/webdriver/

Watir file upload window preventing from further redirection

When I upload photos using watir with this code on windows:
file_input.set("#{Dir.pwd}/photos/" +'image.jpg')
uploading works okay, but a dialog windows appears, and it prevents the script from redirecting to the next page. I don't know how to close it, and I need to find a way to handle it. browser.windows.size shows that there is only one window, and I'm stuck. Can anyone help me?
It is a Windows dialog, it takes over the focus, you cannot click anything else (Watir goes on, but redirection at the end is aborted).
I found solution by preventing default behavior of input element:
browser.execute_script("document.getElementById('file').onclick = function(e){ e.preventDefault() } ")
I don't know if it is good solution but it works fine for me (if not, please notify me), I hope that it would help someone.

Getting screenshot of Child Window

If I have a handle to a window, how do I take a screenshot of any new child windows when they show up? Right now I have code that takes a screenshot every .1 seconds of a windows form. When I click on a drop down list box the subsequent screenshots do not include it. Using spy++ I can see that a new child window was created but not sure how to make sure it is included in my screenshots. Does anybody have any code that might include child windows?
Thanks in advance,
Bob
Yes, the dropdown of a ComboBox is a special window, a LISTBOX. .NET doesn't provide a built-in way to get the handle for it, you can P/Invoke SendMessage and send the CB_GETCOMBOBOXINFO message. COMBOBOXINFO.hwndList contains the handle.
Note that there are other controls that behave that way, DateTimePicker for example. Also note that the window can extend beyond the bounds of your form.
The code in this thread should be helpful to get the P/Invoke right.

Resources