How to Open firefox extension page with Selinium - firefox

I am trying to automate testing for restful API, and I am using Firefox rest-client extension.
If I type in url box "chrome://restclient/content/restclient.html"
This page loaded successfully, however I am unable to open it with Selenium IDE or through Java code
Here is Selenium code
open | chrome://restclient/content/restclient.html
or
<tr>
<td>open</td>
<td>chrome://restclient/content/restclient.html</td>
<td></td>
</tr>
It gives me following error
[info] Executing: |open | chrome://restclient/content/restclient.html | |
[error] Unexpected Exception: Error: Access to 'chrome://restclient/content/restclient.html' from script denied.
[info] Test case failed
I have noticed that, It rejects every thing which do not have http:// prefix
Could someone please suggest how to open this extension page so that I can proceed with my Test?

you can use this for running standalone chrome://restclient/content/restclient.html.
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -new-window -chrome chrome://restclient/content/restclient.html

I suppose that you already have a extension file with .crx extension,if not, you can pack the extension by going in to the developer mode of Chrome.
By using ChromOptions Class you can add particular extension.
Here is the code for chrome, which i wrote and tested. It is working fine in my system.Let me know if you face any issue. Would like to help you.
System.setProperty("webdriver.chrome.driver","C:\\Users\\Maverick\\Desktop\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("C:\\Users\\Maverick\\Desktop\\RestClient.crx"));
WebDriver driver = new ChromeDriver(options);
driver.get("chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html");

Related

How do I find the logs of Firefox build?

I am building firefox browser
In the source code there is the code:
'''MOZ_LOG(sLogger, LogLevel::Debug, ("bug......"));'''
Where will this log be saved?
Doccument build firefox : https://firefox-source-docs.mozilla.org/setup/windows_build.html

Firefox profile not loaded in Open Browser with Robot Framework SeleniumLibrary 4.0

I have created a new profile for Firefox to be used with Robot Framework SeleniumLibrary. However the profile is not loaded using the following
*** Settings ***
Library SeleniumLibrary
*** Keywords ***
Just testing
Open Browser about:blank Firefox ff_profile_dir=C:${/}Users${/}Administrator${/}AppData${/}Roaming${/}Mozilla${/}Firefox${/}Profiles${/}dev
*** Test Cases ***
Just testing
Which profile is used can be seen from page about:profiles
However, when checking about:profiles on a browser launched by webdriver, the profile is not marked as in use: page about:profiles on a browser launched by Webdriver
Any thoughts why Firefox profile is not loaded?
EDIT: How do I know for sure if the profile is loaded or not?
Looking at geckodriver log the directory seems to be totally different
mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\rust_mozprofile2iM6KC"
The reason I have created separate profile is to bypass NTLM authentication using AutoAuth extension when launching automated tests suite.
SeleniumLibrary 4.0.0
Robot Framework 3.1.2 (Python 3.7.4 on win32)
Firefox 69.0.3
I've looked at my custom keyword to setup firefox profile:
from robot.api import logger
from selenium.webdriver import FirefoxProfile
class SeleniumPyExtension:
#staticmethod
def setup_firefox_profile(download_dir):
profile = FirefoxProfile()
logger.info('Download dir is {}'.format(download_dir))
profile.set_preference("browser.download.dir", download_dir)
profile.set_preference("browser.download.folderList", 2)
profile.set_preference(
'browser.helperApps.neverAsk.saveToDisk',
'image/jpeg;'\
'application/vnd.ms-excel;'\
'application/octet-stream;'\
'application/pdf;'\
'application/ogg;'\
'audio/mpeg;'
)
profile.set_preference("pdfjs.disabled", True)
profile.update_preferences()
profile_dir = profile.profile_dir
logger.info('Profile is located at {}'.format(profile_dir))
return profile_dir
and checked what it creates and it occurred that it creates directory with only user.js with bunch of user_pref(...) as described here.

Timed out receiving message from renderer: 600.000 with Chrome v73.0, ChromeDriver 2.46 on Bamboo Server

After chrome browser upgraded to 73.0 selenium test are not getting executed in bamboo build server and working fine when executed locally. Upgraded compatible version of chromeDriver 2.46. Still getting error:
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1554111197.266][WARNING]: Timed out connecting to Chrome, retrying...
Apr 01, 2019 5:33:18 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Force Stop build feature is enabled for current plan. Either Bamboo has detected the build has hung or it has been manually stopped.
Below is code used to launch browser:
public void selectBrowser(String browser)
{
System.out.println(System.getProperty("os.name"));
if (System.getProperty("os.name").contains("Window")) {
if (browser.equals("chrome")) {
System.out.println(System.getProperty("user.dir"));
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir") + "/drivers/chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--verbose");
chromeOptions.addArguments("--whitelisted-ips=");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
driver = new ChromeDriver(ChromeOptions);
}
}
}
Error displayed in bamboo during test execution:
Long Story cut Short John Chen (Owner - chromedriver) have confirmed that:
The root cause is indeed in Chrome 73.x, not in ChromeDriver. We are working with Chrome devs to find a solution.
Solution
A quick fix solution will be to:
Downgrade Chrome Browser to Chrome v72.x
Use a matching ChromeDriver among:
ChromeDriver 2.46
ChromeDriver 72.0.3626.69
Note: If you are using Chrome version 72, please download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69
Ensure that JDK is upgraded to recent level of JDK 8u202.
Alternative
Adding the argument --disable-features=VizDisplayCompositor through an instance of ChromeOptions() seems solves the issue:
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-features=VizDisplayCompositor");
WebDriver driver = new ChromeDriver(options);
driver.get("https://google.com");
Outro
You can find the relevant discussions in:
Page.captureScreenshot no longer works in Chrome 73 under Selenium as a Service on Windows
Error [SEVERE]: Timed out receiving message from renderer: 20.000 while executing the testsuite through Selenium on Jenkins
Download Google Chrome 72 Offline Installer For All Operating Systems

How to troubleshoot when Safari App Extension not appear in Safari Preferences?

I'm developing a Safari App Extension. Previously it worked fine. When I run the project in Xcode, and enable Allow Unsigned Extensions in Safari, I can see my extension in Safari Preferences -> Extensions page.
After I merged code with one of my team member, suddenly the Extension cannot get installed.
I have tried:
Clean the build folder in Xcode, and run again. But no luck.
Restart Xcode doesn't help either.
Use command pluginkit -mAvvv -p com.apple.Safari.extension to check installed Safari extensions list. My extension is not in the list.
There are some errors in Xcode output, but I can't link them with the issue I'm facing:
objc[49476]: Class AMSupportURLConnectionDelegate is implemented in both /System/Library/PrivateFrameworks/EmbeddedOSInstall.framework/Versions/A/EmbeddedOSInstall (0x7fff9a2aa748) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2600). One of the two will be used. Which one is undefined.
objc[49476]: Class AMSupportURLSession is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff9b5d49f0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2650). One of the two will be used. Which one is undefined.
2018-12-13 16:25:46.003099+0800 Safari[49476:1264277] Could not connect action, target class SecurityPreferences does not respond to -toggleJavaScriptCanOpenWindows:
2018-12-13 16:25:46.163130+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 75
2018-12-13 16:25:46.163219+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 396
2018-12-13 16:25:46.163465+0800 Safari[49476:1264277] [Framework-Internal-Legacy] AssertMacros: _xpcClient (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKit.m, line: 137
2018-12-13 16:25:47.060959+0800 Safari[49476:1264368] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:47.128105+0800 Safari[49476:1264277] Scheduling the NSURLConnection loader is no longer supported.
2018-12-13 16:25:47.491811+0800 Safari[49476:1264370] NSURLConnection finished with error - code -1100
2018-12-13 16:25:47.799590+0800 Safari[49476:1264514] [CloudBookmarks] Error fetching remote migration state: Error Domain=com.apple.SafariBookmarksSync.CloudBookmarksErrorDomain Code=0 "(null)"
2018-12-13 16:25:47.953259+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 0) did become unresponsive
2018-12-13 16:25:47.970927+0800 Safari[49476:1264512] NSURLConnection finished with error - code -1100
2018-12-13 16:25:48.032647+0800 Safari[49476:1264425] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:48.125530+0800 Safari[49476:1264426] Calling IOPPFGetProperty simulator_utility_clamp!
2018-12-13 16:25:48.840769+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 49481) did become responsive
Now I'm running out of options. It lacks official documentation in Apple Developer site.
Is there regular steps to troubleshoot this kind of issue? Is there any kind of system logs which can help me address the error? Any suggestion is appreciated.
Make sure that the extension .appex is listed as embedded content for your App Extension target. Otherwise it doesn't get bundled when you build from Xcode. Look in the project editor under Target_Name > General > Frameworks, Libraries and Embedded Content. The extension should be listed there.
Also check under the Build Phases tab > Dependencies that your extension is added there as well.
Check to see if the code signature of your app is valid. Safari will refuse to list your extension otherwise. Run codesign on your built app as follows:
codesign -d --verify --verbose=3 ~/Library/Developer/Xcode/DerivedData/OnePassword-epeydspviethpabprcrsqenrkiin/Build/Products/Debug_WebStore/1Password\ 7.app
It should show valid on disk and satisfies its Designated Requirement. If it doesn't, Safari will ignore your extension completely, even when Allow Unsigned Extensions is enabled.
I had a similar problem more recently after updating to Xcode 13.2.1 and a I think a MacOS update. My Safari web extensions I was developing stopped showing up in Safari (even with unsigned extensions enabled).
In a Terminal/CLI shell, I ended up running:
PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
lsregister -f /Applications/Safari.app
And suddenly my extensions started showing up again in Safari. Something screwy happened with Safari and LaunchServices.

NS_ERROR_FILE_ACCESS_DENIED error when Firefox Addon is installed the second time

We have the Firefox Addon (the .xpi file) hosted locally. The xpi file is downloaded from the Mozilla Addon developer hub and put on our server.
When we install the Addon from the browser, the first time there is no error. Tho, before the Addon is installed there is a prompt that says "Firefox prevented this site from asking you to install software...". When I allow the Addon it installs properly.
But after the Addon is removed and installed again it logs the following errors in the browser's console:
1523369438217 addons.xpi WARN Failed to remove temporary file
C:\Users...\AppData\Local\Temp\tmp-7i8.xpi for addon
https://www........com/BrowserExtensions/FF/pulselinks_window_launch-1.0-fx-windows.xpi:
[Exception... "Component returned failure code: 0x80520015
(NS_ERROR_FILE_ACCESS_DENIED) [nsIFile.remove]" nsresult: "0x80520015
(NS_ERROR_FILE_ACCESS_DENIED)" location: "JS frame ::
resource://gre/modules/addons/XPIInstall.jsm :: removeTemporaryFile ::
line 1493" data: no] Stack trace:
removeTemporaryFile()#resource://gre/modules/addons/XPIInstall.jsm:1493
startInstall/<()#resource://gre/modules/addons/XPIInstall.jsm:1845
Any idea what might be causing the issue?
Firefox latest version
Windows 7 and 10

Resources