Determining if Chrome is in Fullscreen Mode for extension development - api

Unsatisfied with the current extensions and workarounds to enter in a URL while full-screened in Google Chrome, I'm trying to write my own. Is there some kind of Event or Attribute I can check/use with the Chrome API to find out if the browser is in full-screen mode?

Well, there are some extensions out there that does Fullscreen controls.
Right now, if you want to check if Chrome is in fullscreen, you can use simple JavaScript functionality to do this:
var is_fullscreen = (screen.width == window.outerWidth &&
screen.height == window.outerHeight);
Note, the above must be used in a content script.

Related

Selenium WebDriver: is it possible to test WebExtension that inject code to the current page?

I found articles about opening browser extension as a page - but my extension inject JS to the current page - and extension can not inject code to chrome* pages. My only choice is SikuliX? Also with SikuliX I can test the badge of my button. I think that with SikuliX I simulate real user behaviour - such tests about UI interactions looks like more robust for me. Also nice to test CSS correctness.
I tried to setup a hotkey for my extension:
But
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'I') (Python) or driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL + "I") (Java)
do nothing, but I can press Ctrl+I and I see popup-UI opened.
UPDATE: I tried to use pyautogui for mouse clicking - but even with opened extension popup UI driver.window_handles does not include it :(
You can configure webdriver to load your extension in to the browser while launching as well. Once your extension in loaded , it can inject required code that i am assuming makes some changes to html such as adding / removing some html elements or applying some styles which can be then tested using Selenium. You can also execute javascript using selenium.
Sikuli framework is based on image recognition and then simulating user interactions on it using mouse and keyboard . Your test cases might break under these scenarios :
Change in resolution which may even result in layout changes
Change in theme of the application resulting in color changes of ui-elements
It will require focus ,etc.
Currently, I test my extension by comparing expected and actual screenshots, using Selenium web driver, pyautogui (for interactions with extension) and opencv2 (for computer vision), see more at https://www.pyimagesearch.com/2014/09/15/python-compare-two-images/

Recognizing element in an Hybrid App - Android

I am new to Android testing. I am currently trying to automate a scenario. I have attached the snapshot of the app screen:
Scenario:
I need to click on "Clock In".
A screen slides from the bottom as shown in the snapshot.
I need to select an item as shown by the arrow.
The developer is saying that it is a Hybrid app. A lot of confusion here for me as I am able to click on "Clock In", but I am not able to select "DL 380 Memory Upgrade".
Doubts:
How to find whether "DL 380 Memory Upgrade" is in Webview/Native?
If it is an element in the webview, how to locate it? I located "CLOCK IN" as below:
#AndroidFindBy(xpath = "//android.view.View[#resource-id='tab-t0-0']")
private AndroidElement clockInTabBtn;
If its an element in WebView, then its web and you won't find anything in web while searching by resource-id - its native attribute only.
I would recommend to use chrome dev tools for debugging hybrid application.
You can read official docs for setup.
Basically you need:
connect device
go to chrome://inspect/#devices in chrome browser
check phone & allow usb debugging if popup appears
check what webViews chrome spotted and click inspect for the one you need
And now you search for elements and their locators the same way you did in Selenum/Web automation
Don't forget to switch context to WebView in your appium test before you actually searching inside webView.
Good luck!
You can check available view using context and can switch to it using follows code:
Set<string> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println(contextNames);
//To swicth to webview
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
}
}
Please refer this thread for similar issue: https://github.com/appium/appium/issues/7243

webkit vs custom elements v2

is webkit trying to accomplish the same thing as custom elements v2 ?
https://webkit.org/
https://developers.google.com/web/fundamentals/getting-started/primers/customelements
If so will safari ever support custom elements? Apple dev's website claims they will, but then they reference 'webkit' and not 'custom elements'. This makes me worried that Safari 10.1 will still not run the 'custom elements' I programmed for my website. True or false?
https://developer.apple.com/library/archive/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_1.html
If safari will never support custom elements, does anyone know of a 'wrapper' or some way to write custom elements with one source-code base, but also have the website run on safari?
Why would google chrome today (march 28,2017), which supports custom elements, not render properly from iPad, but would work fine when using the browser from mac?
is webkit trying to accomplish the same thing as custom elements v2 ?
Webkit, Safari's Web engine, is trying to implement Custom Elements v1.
If so will safari ever support custom elements?
Yes, at least autonomous custom elements. For customized built-in elements you'll need a polyfill (see below).
does anyone know of a 'wrapper' ?
There are 2 polyfills availables.
Why would google chrome today [...] not render properly from iPad ?
Maybe you version on Chrome or OS X is too old. Maybe you can update them.

Capybara Selenium Navigate To URL Hangs With Popup Alert on Safari

At the end of my tests Capybara automatically navigates to "about:blank" in order to set up the next test. Sometimes the application I'm testing will throw a popup alert if the user leaves the page (which is expected). I have some code to handle this:
begin
page.driver.browser.navigate.to("about:blank")
page.driver.browser.switch_to.alert.accept
rescue Selenium::WebDriver::Error::NoAlertPresentError
# No alert was present. Don't need to do anything
end
This works fine on Firefox, Chrome, and IE. But for some reason on Safari the navigate command hangs, I assume because of the popup. Anyone know a workaround for this?
There is no simple workaround for this at this time in any version of Selenium language bindings. It is a known issue the Selenium team is not interested in resolving. Fundamentally, it is due to the architecture of Safari and consequently the architecture of the Safari Driver.
The JavaScript of the Safari Driver extension does not know about most of the alerts and popups and dialogs that appear as modal Cocoa layer windows.
It also cannot interact with them.
There is a way but it won't be easy and nobody's done it.
You would need to use Cocoa.
So you would want to use RubyCocoa in this case.
(or PyObjC if you used Python)
You would then possibly also want a sidecar app actually written in Objective-C.
The trick would be to use the AX (Accessibility API) and a separate process to observe if there is an alert as the front window and poke at its labels and buttons' text as visible to the AX APIs.
AX APIs are probably exposed in RubyCocoa via the ScriptingBridge.
However, you would need to add your 'app' to the Security preference pane's list of things allowed to control the computer.
With that, you could detect the window and handle it.
It could be fairly brittle across web sites, but if built well, you could handle expected conditions.
You could try to confirm like this which I believe should work across browsers
# click ok to confirm
page.evaluate_script('window.confirm = function() { return true; }')

Best way to display notifications in Opera v15 extension

I have a chrome extension that I adapted to the Opera. Fortunately, all the features of my chrome extension worked well in Opera 15 without many changes. However, my extension uses the webkitNotifications to notify the result of the context menu click. It seems that the web notifications doesn't work in Opera extensions.
var notification = webkitNotifications.createNotification('icon_32.png','My extension title','Notification text');
notification.show();
setTimeout(function(){notification.cancel();}, 5000);
In this case, what is the best way to notify the user when the context menu is clicked? Thanks.
webKitNotifications.createHTMLNotification has been deprecated. New suggested way to create notifications is in draft currently and not many browsers have implemented it.
In the meantime, I'd like to suggest to find another way to notify the user.