I am using a script created weeks ago in Firefox. When I loaded it up, Firefox opens but blanks out and doesn't run.
selenium = new DefaultSelenium("localhost",
4444,
"*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe",
"http://www.test.com/");
selenium.Start();
Do Firefox profiles get in the way? It opens up a new instance of Firefox everytime but doesn't go to the test site.
By writing "http://www.test.com/" for your selenium instance you just provide base url for your tests. To navigate to your test site you should use selenium.open("/") command. To navigate to "http://www.test.com/test.html" you should use selenium.open("/test.html") and so on.
Related
I just got back into selenium testing and I'm using the basics:
initialized on top is
public static WebDriver driver=null;
and then depending on what is set in a properties file, it loads either the chromedriver or edgedriver.
System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")+"//BrowserDrivers//msedgedriver.exe");
driver = new EdgeDriver();
and for chrome:
System.out.println(System.getProperty("user.dir")+"//BrowserDrivers//chromedriver.exe");
driver = new ChromeDriver();
it works for the most part, except it keeps opening two browser pages at once? which eventually leads to a disconnect because it uses the second page opened, then when it tries to close the page (ie, driver.quit()) to start the next test case, it successfully closes the page it ran the first test but because of the first page that was opened, it throws this error:
WARNING: Process refused to die after 10 seconds, and couldn't taskkill it
java.lang.RuntimeException: Couldn't detect pid
I am using the most updated and stable versions of both webdrivers and selenium4.5, and webdrivermanager5.3
I have the following setup:
A Selenium server hub running at "http://localhost:hubPortNum" (a service with the Jar file selenium-server-standalone-3.141.5.jar with parameter -role hub).
A Selenium Node at running "http://localhost:nodePortNum' (the service with Jar file with parameters: -Dwebdriver.chrome.driver=ChromeWebdriverPath -role node -port :nodePortNum).
I checked the URL for the hub and node instances to be sure they are working.
Whenever I try to create Remote Webdriver via Python script:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desiredCapabilities = DesiredCapabilities.CHROME.copy()
chromeOptionsRemote = webdriver.ChromeOptions()
chromeOptionsRemote.add_argument("--start-maximized")
chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")
initRemoteDriver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://127.0.0.1:<nodePortNum>/wd/hub', desired_capabilities=desiredCapabilities)
print(initRemoteDriver.current_url)
The last line does print the current URL(which is "data:,"), that means Webdriver is created.
But the browser does not open on my local machine, that is it is running in the background and I don't know how to make it visible although it has worked in the past.
The troubleshooting steps I have made:
Reinstall latest selenium python package.
Re-Download latest Selenium server jar file.
Updating chrome.
adding chromeOptionsRemote.add_argument("--no-sandbox")
Making sure local Webdriver does open:
That is the line:
self.localDriver = webdriver.Chrome(options=chromeOptionsLocal,
desired_capabilities=desiredCapabilities)
does open the browser locally(the Chromedriver is in the path).
After I made these troubleshooting steps, I have tried the same configuration on a remote server and got the same result(browser not visible), so I think this is probably by design.
what configuration should I create for the browser to be visible?
Any help would be appreciated.
I was running the jar file by Always-Up: https://www.coretechnologies.com/products/AlwaysUp/
The problem was related to session 0 isolation: https://stackoverflow.com/a/26752251/2710840
in order to not run the application under session 0, I have enabled the Autologon feature:
defined the user under the application run as my user:
and executed the application from the context menu with the option to: "restart in this session"
I have installed firebug for FF. But when i start firefox it always starts some default ff version, i dont' know where selenium finds it.
I already googled alot, tried to use different firefoxbinary:
System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
final File firefoxPath = new File(System.getProperty("webdriver.firefox.bin")) ;
FirefoxBinary firefoxBinary= new FirefoxBinary(firefoxPath);
firefox = new FirefoxDriver(firefoxBinary,null);
I tried to use different ff profile:
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.9.1");
Alas, it does not work!
1. I don't know where to change/find webdriver.firefox.bin
2. I have tried changing path as environment variable,still no progress
maybe I m doing something wrong?
By default, Selenium will open a "vanilla" Firefox profile. If you want to have it launch with your profile, you can do that, but you have to select which profile you want to use. I will warn you that you often don't want to have your regular profile used because you'd like a clean, consistent working environment.
But you could certainly:
set up a profile (call it, for instance, selenium-profile using
Firefox's profile manager
run Firefox choosing that profile--from
Windows's Run dialog run "c:\Program Files(x86)\Mozilla
Firefox\firefox.exe" - P" or the equivalent path to FF if you are
32-but.
install Firebug using that profile.
then choose that profile when you launch your tests.
For information about how to do all this, look at this article.
Then, in your code, you can just call that profile. Step 3 in the article linked above shows how to do this.
Firefoxdriver starts a new default profile on each instance and this profile will be created in your temp folder and will be deleted after you quit the driver. There might be some old instances of ff profile which contains older version of firebug in your temp folder which might be not be deleted as webdriver quited unexpectedly.Try clearing your temp. It might help you as it did for me.
I am able to open firefox browser from a browser using sahi script like:
var $path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
//var $name = "firefox";
var $browseroption = " -profile D:\\sahi_pro_V4.0\\userdata\\browser\\ff\\profiles\\sahi1 -no-remote";
_execute($path + $browseroption);
But, when i give _navigateTo after this, it is executed in the first browser itself. Is it possible to run it in the newly opened firefox browser?
This may be late, but one of the following two APIs could be useful depending on your test requirement: _launchNewBrowser and _openBrowser.
I have a set of tests that I've developed using the Selenium IDE in Firefox. Tests run fine and all pass. Now I'm trying to port those over to C# and run the tests for IE using MSTest and selenium-server. Here's the sequence of events:
Run all tests on Firefox via Selenium IDE. All tests pass.
Export tests to MSTest (Nunit export, rename some stuff etc.)
Start selenium-server-1.0.3
Run the tests in VS2008. Selenium setup is: selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/theSite/");; note that I can browse to http://localhost/theSite/ just fine.
4a. Confirm test is launching Firefox. Got result:
17:00:30.290 INFO - Preparing Firefox profile...
17:00:33.842 INFO - Launching Firefox...
First test ( waitForText "Login" in control "ctl00_TopNavBar_LoginStatus1") fails. Can't find the control.
if ("Login" == selenium.GetText("id=ctl00_TopNavBar_LoginStatus1")) break;
or
if ("Login" == selenium.GetText("ctl00_TopNavBar_LoginStatus1")) break;
All other tests fail as well -- same reason. Each test has a waitForText at the top.
Tried running the test in *chrome, *iexploreproxy and *firefox. All fail for the same reason.
Tried dumping a screenshot using selenium.CaptureEntirePageScreenshot("c:\\temp\\screenshots\\seleniumSite.png", "background=#FFFFFF"); and the screenshot is just a white bar.
So, my question is, how do I go about debugging this and figuring out what the real problem is? Clearly the page will render and the tests will pass. It's just when I try those tests in Selenium-RC that it fails so badly. Does the Selenium IDE have some bugs related to exporting tests to C#? (I have noticed one bug).
Are you executing selenium.Start() and selenium.Open()? Do you see the page opened in the browser?
Full initialization should be something similar to:
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/");
selenium.Start();
selenium.Open("/theSite/");
Important Note! test your IDE tests by starting with an empty page. Also, when using the IDE, if a command only has one parameter put it in the Target field, even if it isn't a control name.