Focus chrome window in linux when running using xvfb - xvfb

I am using the following shell script for to get the focus on a specific chrome window:
#!/bin/sh
WIDId=`xdotool search "Test page"`
xdotool windowactivate --sync $WIDId
sleep 2
xdotool windowactivate $WIDId
xdotool key --clearmodifiers ctrl+a
It works when running normally but fails when running chrome using xvfb.
In xvfb it is unable to find the windowID.
I need it to get working with xvfb.

It worked even without using windowactivate because I opened just one window that needed focus.

Related

Electronjs app icons are big when launching in wsl2 using Xlaunch?

I have enabled WSL 2. I have also installed VcXsrv (I think its also called Xlaunch?).
I opened the settings and overrode these properties for XLaunch.exe as shown below:
After that I clicked XLaunch.exe and added -ac in one of the boxes as shown below and then pressed OK. This launched an instance of XLaunch/VcXsrv in my system tray.
Now I opened my terminal (in WSL 2) and git cloned the demo Electron app from their website. After running npm install and npm start, I see a window, but the icons are large.
I also tried adding these environment variables to my shell rc (I am using fish shell).
set -x DISPLAY {mywslip}:0
set -x LIBGL_ALWAYS_INDIRECT 1
set -x GDK_SCALE 2
set -x GDK_DPI_SCALE 0.5
But even after this, Electron app's icons and text is a little bit large. To confirm if this was an Electron issue, I did npm start in my host machine (i.e., using Windows cmd meaning I ran it not in WSL 2, but on host windows machine itself). However in this case, it works perfectly fine, icons are perfectly scaled.
I think I need to play around with these environment variables, but is there an automatic fix without my having to guess the numbers for GDK_SCALE etc?
Note: I have a normal 1920 x 1080p resolution laptop with me.

How to run multiple execute windows batch in jenkins

I am trying to open appium, avd, and ride to run a test in Jeninks. I have the following in execute windows batch command:
C:
cd C:\Users\Gebruiker
appium
adb start-server
cd C:\Users\Gebruiker\AppData\Local\Android\Sdk\emulator
emulator -avd Pixel_3_API_23
ride.py
D:
cd D:\RIDE - testproject\Avans-One
robot -d Open_settings_connect_wifi AvansOne
It keeps loading after opening Appium, the first step. I have tried seperating the steps but it still doesnt work. It completes the first step and then just keeps loading. How do i fix this?
Most probably, this is happening because the command used to start the app is not returning while the app is running. So you will have to use a command that allows you to run the application in the background.
Check with something like below.
START /B title program
e.g.:
C:
cd C:\Users\Gebruiker
START /B "" appium
You can read more about the background process here

Unable to run functional tests on server. [geb spock]

Hi I am running my functional tests using geb.
I am able to run tests on my local computer correctly. but as I deploy my application to server. the build for functional tests fails.
Here is my console output
|Running 10 spock tests... 1 of 10
Failure: |
sign in with voucher
|
geb.driver.DriverCreationException: failed to create driver from callback 'script14007213321291157436758$_run_closure1#77068fce'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
at geb.Configuration.createDriver(Configuration.groovy:346)
at geb.Configuration.getDriver(Configuration.groovy:335)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.go(Browser.groovy:377)
at geb.Page.to(Page.groovy:171)
at geb.Browser.via(Browser.groovy:454)
at geb.Browser.to(Browser.groovy:413)
at geb.Browser.to(Browser.groovy:391)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at VoucherSpec.sign in with voucher(VoucherSpec.groovy:14)
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/local/bin/firefox) on port 7056; process output follows:
Error: no display specified
Error: no display specified
Can anyone guide me to solve this issue.
The server you're running the tests on is 'headless' so doesn't have a display to start Firefox on to run the tests. You've got a couple of options:
Switch from Firefox to a headless browser such as HTMLUnit.
Configure a virtual display on the server.
Use a remote browser service such as SauceLabs.
If you need to test directly on Firefox then HTMLUnit isn't an option for you.
Using a remote browser service such as SauceLabs or BrowserStack has a couple of advantages, for example they record a video of the session and take screenshots, but we found the overhead of passing commands & traffic over the network made the tests unacceptably slow. If you need to test a wide variety of browsers then the overhead diminishes because you can run in parallel...
Option 2, using a virtual display, is the simplest to configure on most servers. If you're using Linux the X Virtual Frame Buffer (XVFB) will get you up and running quickly. It's worth reading up on what's going on but the short answer is:
Install XVFB (sudo apt-get install xvfb)
Install Firefox (sudo apt-get install firefox)
Start XVFB (sudo Xvfb :10 -ac -screen 0 1024x768x8 &). You may want to add an init script so this happens every time the server starts
In your CI server add export DISPLAY=:10 as a step before the tests are run
Run your tests
The XVFB creates a virtual display on :10, which you then set as the default display. When you start Firefox it's completely unaware that it's on a virtual display, so things like getting Geb to take screenshots of failing tests will work as normal.
For more information about the steps see:
http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/
https://github.com/tomaslin/grails-test-recipes
http://www.semicomplete.com/blog/geekery/xvfb-firefox.html
http://www.labelmedia.co.uk/blog/setting-up-selenium-server-on-a-headless-jenkins-ci-build-machine.html
http://manpages.ubuntu.com/manpages/lucid/man1/xvfb-run.1.html
If you need an init script to get it to start/stop, then there are quite a few to choose from, such as this one.

Unable to get chrome driver working through jenkins

I am unable to get chrome driver working via Jenkins. My tests run fine from a terminal window but I wish to run them from Jenkins in headless mode.
I have the latest recommended version of chrome driver installed and Chrome version 28.0.1500.71. Chromedriver has been placed on my path at /Usr/bin.
However when I attempt to run the tests from Jenkins I get an error message:
"Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using chrome binary at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (Selenium::WebDriver::Error::UnknownError)"
I have also tried installing previous version of chrome and chromedriver but I get the same error message.
So after some investigation I found that in order to run headless tests via Jenkins you may need to have installed xvfb. (i say may because I am not 100% sure if this is correct) So I installed xvfb via Xquartz and the xvfb file is also on my path at /Usr/bin.
However even after doing the above with Xvfs I still get the error. Xvfs appears to start successfully as I get the message: Xvfb starting$ /Usr/bin/Xvfb :1 -screen 0 1024x768x24 -fbdir /Users/Shared/Jenkins/Home/2013-07-15_16-24-193595155347701391882xvfb in the console output in Jenkins.
Anybody have any idea what I am doing wrong? I am new to the world of Macs so there may be something I am missing.
Any help would be greatly appreciated!!
Managed to get this sorted. Instead of enabling Xvfb in the job configuration build environment section, I ran it using a terminal command and it now works. So my terminal command is now: xvfb-run cucumber --tags #automated - So this issue can be closed

Powershell why popup window, how to stop it

Not sure why when I execute a Python tools like pip or nosetests inside powershell, a separate popup command line windows will show, execute my command, then disappeared. This is annoying because I can hardly see the executable output, especially the last few lines before the popup close.
I assume there are some setting I can change to stop the popup?
I am using Powershell 2.0 in Windows 7.
Powershell is not cmd.exe, and it has a different console interface. More than likely, your py tools are writing to a non-existent shell window. You may be able to get around this by using the following syntax:
cmd /c script.py
What you do when you execute the python scripts directly from the PS prompt is fire-off a DOS shell for the period of time it takes for the command to complete. Since there's no 'pause' implemented, the shell window closes when the command completes.
A test script
# tester.py, just a test
print "This is a test script, that is all."
Output in PS:
C:\src\python
{powem} [36] --> .\tester.py
C:\src\python
{powem} [37] --> cmd /c .\tester.py
This is a test script, that is all.
mp
For someone has similar problem, please have a look at this answer, I think this solution eventually solved my problem. and in my case, I have to restart my computer to get it all working.

Resources