Is it possible to stop Firefox from popping up when cucumber hits a #javascript tag? After a while it gets frustrating to always get disrupted while running tests.
It would be nice if webdriver was to start Firefox minimized or not focus on it.
There's no API in WebDriver to do this, and it's not really advisable since Firefox won't trigger certain events (like focus, blur) when the window is in the background. I usually work around this by using a virtual machine (e.g. in VirtualBox) or a separate X display.
You can add lines below to Info.plist of Firefox.app. After that it will start without grabbing focus.
<key>LSBackgroundOnly</key>
<string>1</string>
Related
I am working on automating an Android app. We have a screen that has a table wherein the cell values keep on changing in seconds. I have observed that it takes more than a minute for AndroidDriver to execute a single action.
I have read on some other forums about this and got to know that this is how the UiAutomator2 works and it has nothing to do with Appium. UiAutomator2 waits for elements to come to a static state and then performs the actions.
Since the dynamic elements on the screen are unavoidable, is there any workaround for this to make Appium scripts execute with good speed? Let me know what you all think of this. I will really appreciate your comments on this. Thanks.
Yes, that is right. It has nothing to do with Appium itself, but with UiAutomator. UiAutomator takes accessibility snapshots only when the application is in idle mode and the framework itself is not optimized for cases when there are constant changes in the page view. As a workaround, try to play around with waitForIdleTimeout such as setting it to zero or try with setting the disableWindowAnimation to true in the desired capabilities.
You could also try with running the following commands:
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
As a last resort, you could ask for the developers to provide you with a special build that has the animations removed in the source code.
I had the same issue, my specific problem was that the mobile app had a timer in the UI, that was changing its value every second.
Looks like the driver was waiting for the DOM to become idle, so it was SUPER slow because of that.
This simple command fixed the issue for me:
# Python code
driver.update_settings({"waitForIdleTimeout": 0})
Additional references:
https://appium.io/docs/en/commands/session/settings/update-settings/
https://github.com/appium/appium/issues/14155
Is there a way to use Chromium switches after starting it up, or must they be enabled on start up? For example, can switches be passed to the renderer processes, or just to the main process?
I want to turn on paint flashing in Chromium (actually in my Electron app which runs on top of Chromium).
Devtools has a checkbox that turns this on, but I want to be able to turn this on without devtools, and after the app has started.
I know there's a show-paint-rects flag I can use:
chrome.exe --show-paint-rects
In my Electron app, I would need to use app.commandLine.appendSwitch:
app.commandLine.appendSwitch("show-paint-rects");
I also found a ui-show-paint-rects flag that lives in something called the "compositor," but that may be irrelevant for me.
Both of these work, but since Chromium uses a multi-process architecture, I'm hoping that there's a way I can specify that switch, or otherwise, turn on a feature in one process and not have to specify it at startup.
Is there a way to do this in Chromium? (Would be ideal to do this in Electron, but I'm not counting on it)
We're trying to migrate our add-on to message manager and frame scripts.
Previously our add-on used gBrowser.addProgressListener() and nsIWebProgressListener.onStateChange() along with browser.webProgress.isLoadingDocument to monitor network activity.
The question is can I continue using browser.addProgressListener and browser.webProgres.isLoadingDocument in future versions of Firefox or using webProgress from frame script is a better way to do that? Maybe I should use some other technique?
For some reason it doesn't work reliably in Firefox 36.0a1 so I thought I should maybe move the code to frame script. Namely frame's docShell is QI-ed to webProgress to add progress listener there. It also doesn't work in all cases so I guess it's just a bug in 36.0a1.
By "doesn't work reliably" I mean that onStateChange() isn't called when I try navigating by browser.loadURI() method when a blank page is loaded in the current tab. Also webProgress from frame script sometimes "forgets" to send STATE_STOP to onStateChange().
I have installed fresh Arch Linux with linux-ck and awesomewm. After that I have installed google-chrome and started it. Everything works well, but if I open other application (chrome lose focus) and then got back to the chrome, it freezes. Mouse cursor works as expected (cursor changes after hovering link, input field, etc) but view is not updated.
Everything works well again if I change desktop to the second and go back to the first again (mod+2, mod+1). Chrome works, responses etc well.
I bet this issue has something in common with hardware acceleration. If I run some game (steam), lose focus, get back to the game - it shows last rendered screen before focus has been lost (sound is ok, game is responsible but does not update screen).
I use nvidia. Do I need some extra configuration to handle it ?
You want to disable "Use hardware acceleration when available" in Chrome settings.
For me, disabling hardware acceleration as Alex pointed out solved the issue. This bug has been brought forward before in awesome's issues GitHub page.
Apparently, the problem is not awesome. Graphics drivers might be involved but the main suspect seems to be the compositing manager. Running awesome with the "--no-argb" flag and disabling the comp manager seems to solve the problem.
The problem was xcompmgr which caused "freezing" view. I switched it to unagi and all of the problems have gone.
I'm getting a weird error while trying to click on a Capybara Element
I'm using find(:xpath,"//a[contains(text(),'Connect')]").click
(find(:xpath,"//a[contains(text(),'Connect')]").present? return true)
the error I get is:
Selenium::WebDriver::Error::MoveTargetOutOfBoundsError Exception: Element cannot be scrolled into view:javascript:void(0);
i did some research and the only solution i found is that setting the selenium version to 2.16 may fix this issue (i'm using 2.25).
anybody got an idea?
It may happen when the page being tested is not fit into the current window size. If you know such pages where usually these error happening, you may explicitly scroll down before doing the operation on such hidden elements(like click, clear etc). Here the code to explicitly scroll down the page.
In java,
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("javascript:window.scrollBy(250,350)");
From the times I used selenium webdriver to test .NET apps, I would get that error when the issue was exactly what it sounds like: It's looking for an object on the page that it cant scroll to for some reason. In my case it was because some dialogue boxes would appear without scrollbars and the driver had no way to "scroll the object into view"
Can you watch the execution of your test and see if that's the case? I had some luck rolling back to a previous version of firefox because 15+ was (as of about 2 months ago when I had the issue) unsupported by web driver and had this problem periodically. Rolling back selenium versions may help too.
First step though is definitely to watch the execution of the test and see whats happening though. And a good debugging idea may be to try to work through your steps manually yourself to make sure the test works by hand.
Its also worth noting that for the webdriver to be able to execute click the object actually has to be visible. IsPresent doesnt require that, it just searches the page files. Also an issue I ran into. IsPresent will still return true for objects that are not and cannot be made visible on the page (i.e. something at the bottom of the page that you cant see at the time)
Couple of tips here:
Webdriver should ideally be on the most recent update, it's what most use (Unless you're doing Ruby Automation)
Use css selectors, xpath (Whilst rendered), is almost always heavier on both resources and code.
Try defensive coding, first of all ascertain it exists. There are many ways to do that dependent on what package you are using. In ruby you would do page.has_css?('css_string')