We are currently trying to integrate selenium with lighthouse.
When we try with the below command we were able to trigger the lighthouse for 1 url.
lighthouse https://application.com/app --port=1156--collect.settings.maxWaitForFcp="45000" --emulated-form-factor=none--output=html --output-path=./GoogleHome.html
But We want it to be integrated with the selenium so that we can run one full flow from login into the logout.
options.setExperimentalOption("debuggerAddress", "127.0.0.1:1156");
ChromeDriver driver = new ChromeDriver(options);
WebDriverWait wait = new WebDriverWait(driver,20);
// Label: Launch
driver.get(" https://application.com/app");```
with the above code in the selenium script we are getting the below error
Note the URL provided in the script is valid and we can navigate it manually.
Note: the port number dynamically generated in the selenium is used in the command.
Error:
```config:warn IFrameElements gatherer requested, however no audit requires it. +0ms
config:warn FormElements gatherer requested, however no audit requires it. +3ms
Runtime error encountered: The URL you have provided appears to be invalid.
LHError: INVALID_URL at Function.run (C:\Users\AppData\Roaming\npm\node_modu
les\lighthouse\lighthouse-core\runner.js:79:17)
at lighthouse (C:\Users\AppData\Roaming\npm\node_modules\lighthouse\lighthouse-core\index.js:52:17)
at runLighthouse (C:\Users\AppData\Roaming\npm\node_modules\lighthouse\lighthouse-cli\run.js:226:32)
at processTicksAndRejections (internal/process/task_queues.js:93:5)```
Any recommendation on what's missing?
Related
I am trying to execute my code in Firefox, sometimes it works but majority of time i get exception as:
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
Its happening from last week, previously it was working fine for me.
NS_ERROR_NOT_INITIALIZED resembles an attempt which was made to use a component or object which has not yet been initialized. These components usually provide an initialization method, often called Init which must be called before any other methods which are being used.
However, this error message...
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
...implies that the Marionette threw an error while invoking addEventListener as defined in dom.js
Your code trials and the relevant HTML DOM would have helped us to debug the issue in a better way. However it seems the addEventListener was invoked too early even before the DOM Tree was completely rendered. To be more specific addEventListener was invoked even before the Browser Client (i.e. the Web Browser) have attained 'document.readyState' equal to "complete". Generally once this condition is fulfilled Selenium performs the next line of code.
Solution
A quick solution will be to before you try to interact with any of the element on a fresh loaded webpage you need to induce WebDriverWait for either of the following expected_conditions:
title_is(title)
title_contains(title)
An example
Python:
Code Block:
driver.get("https://stackoverflow.com");
WebDriverWait(driver, 10).until(EC.title_contains("Stack"))
print("Page Title is : "+driver.title)
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
Java:
Code Block:
driver.get("https://stackoverflow.com");
new WebDriverWait(driver, 10).until(ExpectedConditions.titleContains("Stack"));
System.out.println("Page Title is : "+driver.getTitle());
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
Additional Considerations
Upgrade JDK to recent levels JDK 8u221.
Upgrade Selenium to current levels Version 3.141.59.
Upgrade GeckoDriver to GeckoDriver v0.25.0 level.
Ensure that the version of the binaries you are using are compatable.
You can find a detailed discussion in Which Firefox browser versions supported for given Geckodriver version?
GeckoDriver is present in the desired location.
GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v69.0 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your Test as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
WebDriverException: Message: Exception… “Failure” nsresult: “0x80004005 (NS_ERROR_FAILURE)” while saving a large html file using Selenium Python
[org.openqa.selenium.WebDriverException: Exception… “Component not initialized” error using GeckoDriver and Tor browser with Selenium Java
Outro
Occur the 'NS_ERROR_NOT_INITIALIZED' when switching the window to bottom dock.
It seems you're suffering from Geckodriver Issue 1263, you can try the following workarounds:
Update Selenium client library to the latest stable which is 3.141.59 as of now, it's better to use package management system like Maven or Gradle as update of dependencies libraries might be required. If you're not using Java check out Web - Desktop and Mobile Browsers article for code examples for different Selenium client languages like JavaScript, Python, C#, etc.
Make sure to use the latest version of Firefox
Make sure to use the latest version of Geckodriver
If you will be still experiencing problems you can consider raising a new issue in the Geckodriver project, be prepared to provide as much information as possible (the same applies to next questions here if any)
On my case, some configs were wrong. I was trying to block pop-up downloads, but something went wrong.Here is the code that I had to remove, and it worked (on this specific case):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", "C:\\Temp");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv");
profile.setPreference("pdfjs.disabled", true);
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.panel.shown", false);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 1);
driver = new FirefoxDriver(capabilities);
I am able to run an extension on browser but a warning "Disable Developer Mode" always block the test case to complete which I resolve by manually clicking to cancel button. I know a command line switch that will disable this warning --force-dev-mode-highlighting but don't know how to use this
Do someone know how?
Following is the code I used to open chrome with extension.
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("C:\\Users\\abc\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\fdpohaocaechififmbbbbbknoalclacl\\2.2_0\\Full-Page-Screen-Capture_v2.2.crx"));
System.setProperty("webdriver.chrome.driver","C:\\Users\\abc\\Downloads\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver(options);
You can use the --force-dev-mode-highlighting switch by invoking an addArguments method that's in the ChromeOptions class:
options.addArguments("--force-dev-mode-highlighting");
However, this switch does not prevent the warning message from showing up.
If the following are used, then Chrome can be run with at least one extension enabled and without the warning (and the code that you've provided will work without the issue occurring):
1. V̲e̲r̲s̲i̲o̲n̲ ̲3̲.̲3̲.̲1 of the Selenium Java Client Driver
2. C̲h̲r̲o̲m̲e̲D̲r̲i̲v̲e̲r̲ ̲2̲.̲2̲8
3. C̲h̲r̲o̲m̲e̲ ̲5̲8̲.̲0̲.̲3̲0̲2̲9̲.̲8̲1
Thanks for the answers. I updated Version of ChromeDriver to 2.29 and that warning problem resolved.
I have the following in my selenium-webdriver test (the test is written as coffee-script):
#driver = new selenium.Builder()
.withCapabilities(selenium.Capabilities.chrome())
.build()
Yet when I run this test the error I get is:
Error: Failed to install profile; firefox terminated with Result(code=-1073
741819, signal=null)
I am perplexed why its trying to start firefox (there is no reference to firefox in my code). Also, at one point this was working. I am not sure what changed in my laptop which has resulted in this behavior.
Thanks for any help.
I am a newbie to Selenium. Created a login test case for my test suite using Selenium IDE, saved it in HTML format, saved in a Test suite.All the test cases in the test suite passes in IDE.
When I run the test suite using Selenium RC using the command:
java -jar selenium-server-standalone-2.40.0.jar -trustAllSSLCertificates -htmlSuite *firefox https://www.com "/home/../../../Automationtestcases.html" "/tmp/test.html".
It enters the username,password,taps on submit but login is not successful.
Am not able to guess the problem? Can someone help?
Example code:
#Test public void testSuccessfullogin() throws Exception {
// ERROR: Caught exception [ERROR: Unsupported command [setSpeed | 6000 | ]]
driver.get("hemoclo.com/hemocloapp/index.html");
driver.findElement(By.cssSelector("input.form-control")).clear();
driver.findElement(By.cssSelector("input.form-control")).sendKeys("dranjali");
driver.findElement(By.xpath("//input[#type='password']")).clear();
driver.findElement(By.xpath("//input[#type='password']")).sendKeys("Dranjali123*");
driver.findElement(By.xpath("//button[#value='Submit']")).click();
try {
assertEquals("Signed in as Anjali Naregal",
driver.findElement(By.linkText("Signed in as Anjali Naregal")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
Try a sendKeys(${KEY_ENTER}) to simulate a click
Based on your code here is one suggestion:
Locate the "id" of your Submit button. Do this by using a tool such as Xpath Helper plugin for Chrome.
The ID (of any element) usually has the following form in the Xpath: #id='button-id'
Once you locate the button ID: replace driver.findElement(By.xpath("//button[#value='Submit']")).click(); by driver.findElement(By.id("button-id")).click();
Another suggestion (more like a sanity check):
Load a completely new session of your browser. (Do not use the browser opened by Selenium). Load your page, enter credentials and hit submit. Check that the page goes through.
I am using friefox 27.0.1 and selenium stand alone 2.15 i am getting below error for click()
RuntimeException: Invalid response while accessing the Selenium Server at : ERROR: Command execution failure. Please search the user group at https://groups.google.com/forum/#!forum/selenium-users for error details from the log window. The error message is: Argument 1 of EventTarget.dispatchEvent does not implement interface Event.
You are extremely out of date. Upgrade to the selenium standalone of 2.40.0 and this will fix your issue.
Source:
Person that had experience with this exact issue.
I updates selenium to 2.39.0 and firefox version to 28 then it worked fine for me.