Running while loop to open new chrome window - selenium

I am running Selenium IDE and trying to write a while loop to open a new chrome window after closing one. I had several attempts with select windows but still unable to run the loop repeatedly.
Here is what I have:
Error:
while on ${var}<=2 Failed:
A window was not selected after closing the previous one, aborting playback.

This error appears because of wrong iterator. execute script | ${var} +1 | command doesn't increase variable var. This command should be replaced with execute script | return Number(${var}) +1; | var
Also You forget to select root window after closing new tab. So after the 10th command should be added select window | handle=${root} |

Related

Listening for newly spawned windows

I have this command:
xprop -spy -root _NET_ACTIVE_WINDOW | awk '{print $5}'
And I need to modify its output for my script to receive an id of the latest spawned window. (My window manager automatically brings focus on a new window). I'm visualizing the end result as this:
1 line output that is either empty or filled with one word, when new window is spawned,
a glimpse of its id pop's up, then it gets stored.

'max_sp_recursion_depth' variable doesn't appear to set causing "Recursive limit 0 was exceeded" error

Quick note, I know this question has been asked here, but the 'answer' gives an alternative which doesn't involve recursion. I want to get recursion working. Here's some code I wrote to demonstrate the problem:
CREATE OR REPLACE PROCEDURE `test` (x INT)
BEGIN
SHOW GLOBAL VARIABLES LIKE 'max_sp_recursion_depth';
IF x = 0 THEN
SELECT 1;
ELSE
CALL `test`(x-1);
END IF;
END
Returns:
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| max_sp_recursion_depth | 64 |
+------------------------+-------+
1 row in set (0.001 sec)
ERROR 1456 (HY000) at line 43 in file: 'workspace.sql': Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine test
What I've tried
I will update this as I try more things:
setting the variable via the MariaDB CLI
setting the variable via PHPMyAdmin
restarting MariaDB
restarted the entire server
restarted my computer (currently running in a development environment on my mac) and the variable has reset to 0
SET GLOBAL ...
does not have any effect on the current connection; only future connections. (Exception: Some variables are "only global"; those probably do show up immediately.)
SET SESSION ...
Is what to do to make it work for the current connection.
I added
max_sp_recursion_depth=255
To the my.cnf file and that fixed the issue. Still unclear as to why the variable wasn't set via the command line, but 🤷 it works. Although I am still interested so if anyone sees this and wants to elaborate, you're an amazing human!

Different result when build delphi project from command prompt and Delphi 10 Editor

I have problem with following code which is written in delphi-10. It excuted properly when it is build from Embarcadero Delphi 10 Editor but when i build module using Command Prompt it gives different result.
Command Prompt build result:
result of Screen.FormCount is zero but there are forms on second monitor
Delphi 10 Build Result:
result of Screen.FormCount is 1 and there is form on second monitor.(which is valid)
might be it is considering only first monitor when running from command prompt.
Monitor:= screen.Forms[Screen.FormCount].Monitor;
Self.Left := Monitor.Left + ((Monitor.Width - Self.Width) div 2);
Self.Top := Monitor.Top + ((Monitor.Height - Self.Height) div 2);
ShowMessage((screen.FormCount).ToString());
what should i do to work build with command prompt.
Hi #RemyLebeau i debug it again i found that when i build through IDE form count is 2 there are two form open one is from1 and second is MDIchildform but when i build through command prompt it gives form count 1 and only form1. may you please tell why MDIChildform is not consider in command prompt build,eve those both form are in same dll
if(screen.Forms[0].Name <>'') then
showmessage(screen.Forms[0].Name);
if(screen.FormCount >0) then
showmessage(screen.Forms[0].Name);
if(screen.FormCount >1) then
showmessage(screen.Forms[1].Name);

Keeping the focus after opening a new window in the Selenium IDE

I'm having a problem retaining the focus after using the openWindow command in the IDE. This problem only applies when a second test case within the same test suite tries to interact with the newly-opened window. For example, I have a test suite consisting of separate test cases to do the following:
Log into site A
Enter some transactional data
Submit the transaction for approval
Open a new window and log into site B
Approve the transaction in site B and close the window
Continue processing the transaction in site A
If I do the test case 5 "site B" actions in the same test case as the "openWindow" (ie. merge test cases 4 and 5) then all commands execute without error. If I do the same actions in a different test case then the new window loses the focus and all Selenium commands are directed back to the original window.
The interesting part of this is trying to identify and reselect the "new" window in step 5.
Executing "selectWindow name=siteB_URL" in test case 5 results in the error message "Window does not exist. If this looks like a Selenium bug...".
I then figured I'd call storeAllWindowNames and echo the results to at least see the window names Selenium knows about at various points. If I do this as the last two commands in test case 4 I get the expected result - "echo ,siteB_URL" is logged. If I do the same thing as the first two lines in test case five I get "echo ". This is the part that gets me - simply changing test cases seems to lose the reference to the new window.
Has anyone come up with a workaround or solution to this problem in the Selenium IDE?
I've spent several hours this morning scouring the web and various forums looking for suggestions to no avail.
Thanks in advance,
Glenn
4-7-12 - Update - here's a simplified example of the scenario above:
[info] Executing: |openWindow | http://www.google.com.au | google2 |
[info] Executing: |selectWindow | google2 | |
[info] Executing: |storeAllWindowNames | allWindows | |
[info] Executing: |echo | ${allWindows} | |
[info] echo: ,google2
[info] Changed test case
[info] Executing: |storeAllWindowNames | allWindows | |
[info] Executing: |echo | ${allWindows} | |
[info] echo:
[info] Executing: |selectWindow | name=google2 | |
[error] Window does not exist. If this looks like a Selenium bug, make sure to read http://seleniumhq.org/docs/04_selenese_commands.html#alerts-popups-and-multiple-windows for potential workarounds.
Have you check it with following commands?
selectFrame | relative=up
selectFrame | iframe name
Try with option:
selectWindow()
Just provide the window title name within ().
For Ex:
Window Title is Testing, then
command : selectWindow
title : Testing
To know the title of the newly opened window follow the steps:
Go to the new window
Right click->view page source
Press ctrl+F.
Type title and search.
You will get the title of the new window.
I hope this helps...
Thanks
Sathiya
//on the original window...
command: store window handle
target: myVar
//...do whatever...
command:select window
target: handle=${myVar}

"result is null" error when working around _blank deficiency in Selenium IDE

Using a workaround to be able to check the contents of a new tab, I get unexpected results. If I play the test case, the following line fails:
storeEval | javascript{"selenium.browserbot.getCurrentWindow().open('', 'my_window')"} | my_window
with the following error message:
[error] Threw an exception: result is null
The following alternative statements show the exact same symptoms:
getEval | window.open("", "my_window")
getEval | selenium.browserbot.openWindow("", "my_window")
Now, if I double-click it, it doesn't fail, but it opens up a new window, which I think the original solution didn't intend (the next step is to click on a link in the parent window, after all). At this point I can click on the parent window, manually run the next step to launch the link, manually change back to the child window (selectWindow | my_window says it can't find that window), and manually run each of the following steps to check the contents of the new window.
How do I proceed from here to make the test properly automatic?
Update: There is a built-in action for opening windows, but it also fails. Maybe this verbatim log output can shed some light on what's going on:
[info] Executing: |store | license_window | windowName |
...
[info] Executing: |openWindow | | ${windowName} |
[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/recorder.js, lineNumber -> 74
The relevant lines from recorder.js:
66: window.open = function(url, windowName, windowFeatures, replaceFlag) {
...
74: if (result.wrappedJSObject) {
75: result = result.wrappedJSObject;
76: }
It seems that your browser doesn't allow pop-up for your web site. Go to options > Content > Exceptions for block pop-up windows and add your web site address.