Integrate sikuli with selenoid to handle non html windows/Image based testing - selenoid

My scripts are working fine locally and same are not working with Chrome browser running in docker container of selenoid. How to integrate sikuli with Selenoid to handle file upload window(non HTML) in chrome browser which is running in docker container ?Any working example pls if it is possible

I have not used sikuli but here is what you can do to send file that is on your server, to the Selenoid browser
from selenium.webdriver.remote.file_detector import LocalFileDetector
input = driver.find_element_by_css_selector("input[type='file']")
driver.execute_script("arguments[0].style.display = 'block';", input)
driver.file_detector = LocalFileDetector()
input.send_keys("/path/to/file/on/machine/which/runs/tests")

Related

How to use selenium with autoit for file upload in a Headless chrome browser?

I'm trying to automate a webpage in selenium on a chrome browser which is integrated into a TeamCity server.
The code is working perfectly in my local machine.
File upload is done with Autoit scripts but when running through TeamCity on chrome browser ,typically as a headless chrome browser ,the script fails as it fails to find the next element(The file uplod fails).
This is not possible...
Headless browser cannot interact with os components(open dialog box)
You can use sendkeys to input field(browse button),which will not trigger open dialog box, since the browser is headless and you can skip using Autoit for headless browsers, which needs a Gui.

is possible run selenium with headless browser to handle functionalities?

My objective is running automation based selenium webdriver from Jenkins, but jenkins cannot open browser when build job. so I modified my code to run in headless mode. since implementing headless browser, having some big question
is possible to handle end to end business on headless browser? cause end to end need inspect element as the process
if headless browser cannot handle, do you have some suggestion?
thanks, I'm very low to integrate automation
You don't have to change the code to run a Selenium test with Jenkins in headless mode.
You can use a Jenkins plugin of a headless X server to run your tests on an installed browser. You will even get screenshots.

how to upload a file to selenium test running in docker

Am running my selenium java tests in Docker's chrome container installed in my windows system.
Tests to upload will pass if i run tests in windows - chrome, but failing with error path is not absolute: D:\xyz.csv if i run same tests in docker.
Am pushing my tests on chrome node in docker.
Normal selenium tests work in docker, but upload doesn't.
Please suggest on how to copy this file inside container to give that path for upload tests..
Thanks
That is because Chrome would look for that path in the system where it. But the container is a linux based system and the file paths are not like this.
So you need to share volume while launching the chrome container
docker run -v localfolder:containerfolder
and in your test you need to use the contaienrfolder path and not the localfolder path
I got the solution of this problem long time back.
Use below command to copy the files from windows/Linux system to Chrome container running in docker's say 'tmp' folder , this path can be later referenced in selenium tests running in Docker.
"docker cp D:\file.csv docker_chrome_1:/tmp/"
This above command can be run once Docker's Chrome container is up and running in Windows/Linux machine.

How to configure Jenkins to run Selenium scripts on a Headless browser on Windows

I am trying to setup Jenkins to run my Selenium scripts on a Headless browser on Windows. I just found that xvfb only works for Unix based OS but not on Windows. Can anyone please help in configuring the same ?
I tried searching on Google but couldn't find anything helpful.

A GUI to debug phantomjs script

I am using phantomjs to build a web crawler. My current crawler is a Python script using selenium, which requires a running Firefox browser. While Selenium is good for debugging scripts (as I can use firebug to inspect the webpage), it cannot be deployed on linux servers without GUI. So I am trying to translate my Python script to phantomjs.
To debug phantomjs scripts, I save the page source html and render a png screenshot to disk, and open it in Firefox to inspect the source page. I am wondering if there is a better way to do this, e.g. a plugin for phantomjs, etc.
This little hack is using a simple technique: It grabs the screen as PhantomJS or CasperJS sees it with captureBase64('png') and then it is POSTing the image into the receiving server which then sends it via socket.io to the browser which displays it is as inline image.
The source code is available on github:
https://github.com/maciejjankowski/flaming-octo-puss
I'm not sure if PhantomJS has it, but CasperJS does (and the latter adds some extra functions to PhantomJS)
and use remote debugging as others suggest
As for most of the JS scripts, it's not so trivial to debug phantomjs script, because there is no IDE/compiler behind this.
First, I higly suggest you to read the Troubleshooting section.
As said by torazaburo, your best option is to use Remote Debugging : scripts can be run in a Web Inspector interface-like console : step-in, step-out, break points, local variables... many classic debugger features are available. If you're familliar with Chrome developpers tools, it's pretty the same.
Though not a solution to your Phantomjs troubles,I think Selenium with Python bindings can be used very efficiently as a headless scraper in a Linux environment.
You can use PyVirtualDisplay, a Python wrapper for Xvfb and Xephyr to fake a display.PyVirtualDisplay needs Xvfb as a dependency. On Ubuntu, first install Xvfb:
sudo apt-get install xvfb
then install PyVirtualDisplay from Pypi:
pip install pyvirtualdisplay
Sample Selenium script in Python in a headless mode with PyVirtualDisplay:
#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
# now Firefox will run in a virtual display.
# you will not see the browser.
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print browser.title
browser.quit()
display.stop()