LeanFT open browser window and navigate - java

I recorded a test case with Test Recorder tool in LeanFT with Chrome. When I execute it, it opens a new tab in Chrome, instead of starting a new instance of application. I tried to execute it in Firefox, but in this case it just opens browser window, doesn't navigate to given url.
Browser browser = BrowserFactory.launch(BrowserType.FIREFOX);
browser.navigate(env.LOGIN);
Error message:
com.hp.lft.sdk.GeneralLeanFtException: launch browser timeout occurred

When you execute a test, it's a new session.
This means that it's your responsibility to make sure that the environment in which your code is running is appropriate.
If you use .launch
while you have Chrome opened, it'll open a new tab
while you have Chrome closed, it'll open chrome (new window)
no matter if you have firefox opened or closed, it'll open a new firefox window
As you can see, the same method causes different behavior, depending on the browser and the state of the environment during the execution.
You need to adapt depending on your needs, and decide whether you want to .launch a browser or .attach to one.

.navigate should contain the URL such as browser.navigate(“www.google.com”) unless you have env.LOGIN set as a string of the url?

Related

geock driver not responding

hi guys I wrote a software that needs to be permanently entered into a website and then perform a browser operation then close and open it again, and each time it opens, the browser profile changes ... but usually after 10 attempts, it seems that the Internet is cut off and the website dont open, but if I create a new tab myself, I can go to the same address manually ... Why does this happen ??... I use Firefox and geockdriver and of course selenium libraries
i created multiple Geockdriver.exe and tried to use each for one profile and also i set port for driver with profile.setPreference(FirefoxProfile.PORT_PREFERENCE, 65535); but still same problem happend
by the way i code in java
selenium-firefox-driver 4.1.3
firefox version 98.0.2

How to attach a chrome window to a desktop application Selenium?

My problem is when I click on a desktop icon, it opens a link in already opened chrome browser in a new tab. How do I attach with the already opened browser and not a new one?
The below code returns a null because there is no window opened through selenium ofcourse, so yeah.
Set<String> windows = webdriver.getWindowHandles();
System.out.println(windows);
Any suggestions would be of great help. Thanks In advance.
There is no way to attach the chrome window that you've opened from the desktop application to your WebDriver instance.
If you want to be able to control a web page with a Selenium - you must pass your URL to a driver like that:
webdriver.get("https://www.your_link.com");
You might think about the way of getting and storing your URL as a variable and passing it into your code.
That would also be helpful if you add a bit more details about the problem. It's a bit unclear at what stage of the test you open the web page with a desktop application. Selenium can't be used to test desktop applications. Code sample of the test from your project would also help.

How to get browser window front while running the test using selenium webdriver?

I'm currently running my selenium webdriver tests in 2 browsers (studentdriver and tutordriver)
studentdriver = new ChromeDriver();# opening student in chrome browser
tutordriver = new FrefoxDriver();#opening tutor with firefox browser
and I'm student browser first and then tutorbrowser soth that student browser will be behind and tutorbrowser will be on front side. when script running with studentbrowser, it will automatically comes fron and tutorbrowser will be back side but when script start running using tutorbrowser it is not coming front side and it is creating some problem in between.
I need a solution to get tutorbrowser front when script start running on tutorbrowser.
Note: I should not close studentbrowser because I'm closing both the browsers in #After
((JavascriptExecutor) driver).executeScript("window.focus();");
try this with each driver.
Unfortunatly, this is an OS problem. It's up to the window manager to handle the ovelapping, tiling, organisation of the windows, which you can't control directly from your code.
The best bet you'll have is to launch a Sikuli Robot with which you'll be able to bring back the correct window. It's a bit of work, though, to include in your tests, but it can be used from Java with no problem
See the beast at http://www.sikuli.org

Execute Selenium Commands on a Browser that is already open

I am looking for an example code that will allow me to run Selenium commands against a browser that is already open.
Typically when you start testing with Selenium it opens a new instance of the browser. But I am looking
for a solution where you would run the script and it will just start executing its codes on whatever browser and tab is currently visible.
Is that possible?
As per my knowledge this is not possible with selenium.
You have to open browser during the test script only otherwise it won't be able to identify or capture already opened browser's object.
No its not. There is an old issue still open since 2009.

selenium server launching two test execution tabs in firefox

So as the title suggests, when launching my HTML suite with a custom firefox profile (also with multiwindow), the server is launching two tabs, both trying to execute the test, targetting the same single window the actions are being carried out in. If I close one of the selenium tabs, the test will then complete successfully.
The custom profile is a profile created in firefox 19.0.2 and I am now running it in 20.0
Now If I update up the custom profile to coincide with the latest version of firefox, this fixes the tab issue when launching the test...however my question is....
Does anybody know the cause of this behaviour?
Many thanks,
Joe
I think Firefox opens the second tab because the current milestone of the browser software does not match the value of the setting browser.startup.homepage_override.mstone in prefs.js: The browser tries to show sort of a successful-update-page in a new tab.
According to https://bugzilla.mozilla.org/show_bug.cgi?id=102313
you can suppress this behaviour by manually setting browser.startup.homepage_override.mstone to ignore. For me, this single change in prefs.js did the trick.
halfbit

Categories

Resources