cancel
Showing results for 
Search instead for 
Did you mean: 

how to prevent launching browser with focus in address bar

SOLVED
kerriem
New Contributor

how to prevent launching browser with focus in address bar

New to TestComplete and trying to automate my first test of launching our WebUI application in any browser (tried in Chrome and Firefox). 

I am writing the script in Python and have the following: 

 

#Launch WUI Login Page
Browsers.Item[btFirefox].Run(Project.Variables.WUI_LoginURL)

browser=Aliases.browser
#Maximise browser window
browser.BrowserWindow.Maximize()

 

At this point, our login page launches correctly and the cursor should be in the Username field, however it is sitting in the address bar of the browser window instead.

If I launch the WebUI application myself though the cursor appears in the Username field fine.

 

Having read a bit in the forums I found an article which suggested using Click() to click into the login page, however the default location for the click is centrally on the page it appears, which clicks me into the password field instead.

I would prefer to avoid the Click entirely and actually be able to verify that focus/cursor is automatically in the Username field but I cannot find a way to do this.

 

I am able to proceed using SetText and type in the Username field without a problem, however I would really like to be able to prove that focus is in the Username field on launch.

 

Any help appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
ebarbera
Staff

Re: how to prevent launching browser with focus in address bar

Hello @kerriem 

 

Have you tried a Keys operation into the URL field? Maybe it requires being typed instead of a SetText operation.

View solution in original post

7 REPLIES 7
Marsha_R
Community Hero

Re: how to prevent launching browser with focus in address bar

After you open the browser, try relaunching your page with this

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/page/tourl-action-pag...

 

 

kerriem
New Contributor

Re: how to prevent launching browser with focus in address bar

Thanks, tried that but still the cursor/focus remains in the address bar of the browser 🤔

Marsha_R
Community Hero

Re: how to prevent launching browser with focus in address bar

Try recording a keyword test and walk through the steps manually and see if you can paste or type the url in the bar and have the cursor come out where you want it.  

kerriem
New Contributor

Re: how to prevent launching browser with focus in address bar

Tried recording both a keyword test and a script, and in both cases the only thing it registered was a Navigate to the URL I typed.

I added the Navigate command to my script after the Run command just in case, but still the cursor remains in the URL bar.

I have repeated the test on Chrome, Firefox and Edge now and in each case the cursor displays in the URL bar, not the username field, but if I type the URL manually it's in the username field for sure.

I am at a loss as to why Test Complete is launching it in this way 🤔

ebarbera
Staff

Re: how to prevent launching browser with focus in address bar

Hello @kerriem 

 

Have you tried a Keys operation into the URL field? Maybe it requires being typed instead of a SetText operation.

View solution in original post

sonya_m
Community Manager

Re: how to prevent launching browser with focus in address bar

Thanks for your help, everyone!

 

@kerriem did the latest suggestion help? Please share your results with the Community.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
kerriem
New Contributor

Re: how to prevent launching browser with focus in address bar

Thank you @ebarbera that worked!
I added:

Aliases.browser.BrowserWindow.Keys("[Enter]") and this effectively was pressing go to move focus to the username field as it would if I entered the URL manually and pressed Enter.

Many thanks!

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors