Getting error while operating multiple windows in robot framework - robotframework

I am doing operation on 3 window.Using select window command in robot framework I will travels to 1st child window and in same way on 2nd child window.But after completion of task on 2nd window it will close automatically and then if I used select window for selecting again 1st window it will shows following error
Error:
"NoSuchWindowException: Message: no such window: target window already closed
from unknown error: web view not found"
Code:
#{Window_list} = Get Window Names
Select Window #{Window_list}[1]
#Do some Operations On 1st window
#Launch Second window
#{Window_list} = Get Window Names
Select Window #{Window_list}[2]
#Do some operations on 2nd window
#Save the changes on 2nd window it will close 2nd window automatically
Select Window #{Window_list}[1]...........#fails at this keyword
If anyone has solution on this please mention.Thanks

I do not know exactly the reason, but I've met this case and solved by using Run Keyword And Ignore Error.
In your case:
Run Keyword And Ignore Error Select Window #{Window_list}[1]

Related

Selenium stopping mid-loop without any error or exception

I was working on a project to scrap data for multiple cities from a website. There are about 1000 cities to scrap and during the for-loop, the webdriver window simply stops going to the requested site. However, the program is still running and no error or exception is thrown, the webdriver window just simply stays at the same webpage.
There is a common feature regarding the webpage that it stopped at, which is the windows are always the ones requesting the button clicks. The button click parts of the code should be correct as it is working as desired for hundreds of cities before the suspension.
However, every different run the program is stopping at different cities and I find no correlation between the cities, which leaves me very confused and unable to identify the root of the problem.
data_lookup = 'https://www.numbeo.com/{}/in/{}'
tabs = ['cost-of-living', 'property-investment', 'quality-of-life']
cities_stat = []
browser = webdriver.Chrome(executable_path = driver_path, chrome_options=ChromeOptions)
for x in range(len(cities_split)):
city_stat = []
for tab in tabs:
browser.get(data_lookup.format(tab, str(cities_split[x][0])+'-'+str(cities_split[x][1])))
try:
city_stat.append(read_data(tab))
except NoSuchElementException:
try:
city_button = browser.find_element(By.LINK_TEXT, cities[x])
city_button.click()
city_stat.append(read_data(tab))
except NoSuchElementException:
try:
if len(cities_split[x]) == 2:
browser.get(data_lookup.format(tab, str(cities_split[x][0])))
try:
city_stat.append(read_data(tab))
except NoSuchElementException:
city_button = browser.find_element(By.LINK_TEXT, cities[x])
city_button.click()
city_stat.append(read_data(tab))
elif len(cities_split[x]) == 3:
city_stat.append(initialize_data(tab))
except:
city_stat.append(initialize_data(tab))
cities_stat.append(city_stat)
I have tried using WebDriverWait to no appeal. All it does is simply make the NoSuchElementException become a TimeoutException.

How to fix List Box returning null value using UIA wrapper

I want to access text values from a List BOX (pywinauto uia wrapper)that is nested inside LIST view inside the application used.
code snippet:
#upper window
up_window.ListView.wait('visible').Select('Enforcement').click_input(double=True)
time.sleep(5)
#after this enforcement window opens and i need to select the third tab which is performed below and its working fine.
enfwin = guilib.get_window('Enforcement', backend='uia')
# guilib is user defined library which will retun the window handle
if enf_win.TabControl.get_selected_tab() != 2:
log.debug("Clicking on 'Targets' tab in Enforcement window")
enf_win.TabControl`enter code here`.wait('enabled', timeout=60).select(2)
time.sleep(30)
list_rows = enf_win.ListBox.wait('ready', timeout=60).texts()
dcs_win.ListView.wait('visible').Select('Enforcement').click_input(double=True)
time.sleep(5)
enf_win = guilib.get_window('Enforcement', backend='uia')
if enf_win.TabControl.get_selected_tab() != 2:
log.debug("Clicking on 'Targets' tab in Enforcement window")
enf_win.TabControl.wait('enabled', timeout=60).select(2)
time.sleep(30)
list_rows = enf_win.ListBox.wait('ready', timeout=60).texts()
The problem here is, when I am calling this function two times from script, 1 st run its fetching the list_rows whereas in second run its returning blank. It seems like it needed some time in between. But increasing time is not helping.
Please suggest if any modification I need to do to fetch list box value each time.

AutoIT get child window from a parent window

I came across a problem which looks trivial to me but I can't find a valid solution after googling for an hour.
I want to fill in a window security popup window.
This is part of a selenium test, that can run in parallel next to other tests.
So in order to be sure that my autoit script fills in the correct popup (and not form another test that is running), i want to identify this popup as a child of a parent window. Is there an easy way to do this?
The code i had so far:
$browserHandl = WinWait($parentTitle)
WinActivate($browserHandl, "")
$popUpHandl = WinWait("Windows Security")
So my fear is that WinWait will return one of all the open Windows Security popups currently open on the machine.
So:
1. Is there a way to obtain the childwindows of a parent window when i got its handle?
2. Is my fear correct that i indeed will have a race condition with multiple tests running at the same time?
input box open
input box hidden
I used a progress to hide what I needed to.
add #include
$file = GUICtrlCreateInput("", 10, 5, 350, 25)
You need 3 lines for the Marquee
Local $iProgress = GUICtrlCreateProgress(30, 10, 270, 20, $PBS_MARQUEE)
GUICtrlSendMsg($iProgress, $PBM_SETMARQUEE, 1, 50)
and to make it cover the input box
and 0 to stop and remove the Marquee GUICtrlSendMsg($iProgress, $PBM_SETMARQUEE, 0, 50) ; Send the message $PBM_SETMARQUEE and wParam of 0 to stop the scrolling marquee.

Issues with Zsh prompt

My Zsh prompt cursor is sometimes (most of the time actually) a line below were it should be (attaching screenshot):
If I hit enter multiple times, the prompt seems to get fixed:
My first thought is that it was an error within my custom prompt, so I replaced by prompt with a simple one containing only one digit:
PROMPT='> '
But the error persisted.
Any clues about what can be missing?
You can find my theme here: http://pastebin.com/cSJwGWKZ.
Notice that I'm using Oh My Zsh.
EDIT: The prompt seems to get fixed when I reach the bottom of the terminal (by hitting enters).
The culprit is %{$(echotc DO 1)%} in your RPROMPT, which moves the cursor one line down when printing RPROMPT. When reaching the bottom of your terminal there is no additional line to go down to, so the cursor just remains where it was.
Depending on where you want your RPROMPT you have basically two options:
On the same line as your input cursor (after λ):
Just remove %{$(echotc DO 1)%} from your RPROMPT:
RPROMPT='$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%'
One line (or any other number of lines, really) above your input:
Add %{$(echotc UP 1)%} at the beginning of your RPROMPT, this will move the cursor up one line, print the right prompt and move back down one line:
RPROMPT='%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'`
Note: the second method may lead to RPROMPT overwriting parts of PROMPT if both get to long and/or the terminal window to narrow. If RPROMPT remains on the same line as input, it will be hidden once the input reaches it (and will reapper if you delete some of the input).

Displaying 2nd Window Issue

I am dealing with 2 windows . One is created by Qt Designer and i import it
on test.py program . what i did i make a Widget on the test program and
than add a button to it and on click event I try to popup the other
window(gui1.py) created by Qt Designer but it never pop ups and when i use
break and do line by line debugging it shows me this message after running
this command "myapp2 = MyForm()" on line number 35 test.py .
QCoreApplication::exec: The event loop is already running
and once i pressed enter on the terminal it pop up the other window .
I am confuse where i am wrong .
Thanks
test.py
gui1.py
The reason the other window doesn't appear, is because you are not keeping a reference to it, and so it gets garbage-collected immediately after it is shown.
To fix the problem, you could either store the window instance it as an attribute, or give it a parent:
def local_manag(self):
print "pressed"
# store it as an attribute
self.myapp2 = MyForm()
self.myapp2.show()
# or give it a parent
# myapp2 = MyForm(self)
# myapp2.show()

Resources