I'm accessing Google images with a headless linux chromeDriver browser. Here are my headers:
`
headers = ({'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit\
/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'})
`
I'm downloading an image from an XPATH. My script works fine on my desktop. But as I cronjob this script from a linux server with a headless Linux chromeDriver browser, it's downloading an image from a different XPATH.
The problem is that I can't manually see which XPATH the script is downloading whilst on the Linux server.
However, I'm certain this is a "browser" problem because I understand that XPATHs are different between browsers. Are my headers (above) telling my script to use Firefox? Am I actually using Chrome?
On my desktop, I'm running Chrome 108 on macOS (Big Sur) and my script works fine.
Tried:
# Finding 2nd image
small_image = browser.find_element('xpath',"//*[#id='islrg']/div[1]/div[2]")
print("Clicking...")
small_image.click()
time.sleep(2)
# Expanding image to full resolution
big_image = browser.find_element('xpath',"//*[#id='Sva75c']/div[2]/div/div[2]/div[2]/div[2]/c-wiz/div[2]/div[1]/div[1]/div[2]/div/a/img")
time.sleep(5)
# Download image
imageURL= big_image.get_attribute('src')
Actual result:
got attribute('src) of SMALL_IMAGE instead of BIG_IMAGE, from what I can see.
"codeceptjs": "^3.0.2"
"#wdio/selenium-standalone-service": "^6.8.0"
"webdriverio": "^6.8.0"
Sample code:
I.amOnPage("https://www.pdfpdf.com/samples.html");
I.click('//a[#href="samples/Sample2.PDF"]');
I.switchToNextTab();
I.closeCurrentTab();
When above code is run in normal mode (non-headless) with or without stepByStepReport enabled, it works fine.
When above code is run with headless mode and stepByStepReport enabled - it hangs at I.switchToNextTab()
Looks like it is not able to take screenshot here
I switch to next tab
» Screenshot has been saved to
<>\0002.png
But 0002.png is not found. We have files only till 0001.png
When the code is run with headless mode and stepByStepReport is disabled, then it works fine.
So problem seems to be with:
Headless + stepByStepReport enabled + Link opens a PDF file
Any thoughts or suggestions on this?
It looks like still not supported in headless mode: https://github.com/puppeteer/puppeteer/issues/1872
I have a raspberry pi configured to boot chromium full screen which works great. However, I want my non-techy user to update the website by simply editing a file on the desktop.
/etc/xdg/lxsession/LXDE-pi/autostart:
# Link to the settings file on the desktop
source /home/pi/Desktop/websetup.config
# start chromium
#chromium --noerrdialogs --kiosk $website --incognito
I would like to have a setup file on the desktop which my user can update the website and overscanning etc without directly editing any config files above:
i.e.
websetup.config:
# Enter website to show
webbsite=https://newWebsite.com
# Overscanning on = 1, turn off = 0
overscan=0
I, however, can output $website from a .sh bash but I cannot work out how to pass the value $website to chromium as I cannot pass the actual value
ok, I have managed to work it out. I created a script called run_chromium.sh:
##
## this file is referenced in: /etc/xdg/lxsession/LXDE-pi/autostart
##
## website to show
website=https://www.website.com
## 0=overscanning off, 1=on
overscanning=1
and I linked to this script in autostart:
/bin/bash /home/pi/Desktop/run_chromium.sh
Good day all,
I'm working on automating some Ruby scripts to make them headless. My initial approach
was to try Watir and its PhantomJS module. Our local test environment uses a self-signed
certificate that I know some browser will error out on. I know that PhantomJS has a
ignoreSSLerrors option but don't know how to specify that the PhantomJS driver should use
it. I can create a headless browser phantom-js session without any problem but when I try
to navigate to the webpage using the self-signed certificate, I get nothing - no errors, no
text, no indication of why my page wasn't loaded.
Basically, this is what happens (the odysseyURL was defined elsewhere as a string URL that
Firefox can load without a problem):
irb(main):035:0* driver = Watir::Browser.new :phantomjs
PhantomJS is launching GhostDriver...
[INFO - 2013-12-05T15:48:49.998Z] GhostDriver - Main - running on port 8910
[INFO - 2013-12-05T15:48:50.219Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
-_decorateNewWindow - page.settings{"XSSAuditingEnabled":false,
"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"
javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,
"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.34 (KHTML, like
Gecko) PhantomJS/1.9.2 Safari/534.34","webSecurityEnabled":true}
[INFO - 2013-12-05T15:48:50.252Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- page.customHeaders: - {}
[INFO - 2013-12-05T15:48:50.262Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- CONSTRUCTOR - Desired Capabilities:{"browserName":"phantomjs","version":"",
"platform":"ANY","javascriptEnabled":true,"cssSelectorsEnabled":true,
"takesScreenshot":true,"nativeEvents":false,"rotatable":false}
[INFO - 2013-12-05T15:48:50.283Z] Session [bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15]
- CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":
"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":
"windows-8-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":
false,"databaseEnabled":false,"locationContextEnabled":false,
"applicationCacheEnabled":false,"browserConnectionEnabled":false,
"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,
"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2013-12-05T15:48:50.327Z] SessionManagerReqHand -
_postNewSessionCommand - New Session Created: bc1bd280-5dc4-11e3-8b99-7bac3d2f1d15
=> #<Watir::Browser:0x73fac05c url="about:blank" title="">
irb(main):036:0>
irb(main):037:0* =begin
<en processed and works headless. Everything below is still being modified
irb(main):039:0= =end
irb(main):040:0*
irb(main):041:0* driver.goto(odysseyURL)
=> "about:blank"
irb(main):042:0> puts(driver.text)
=> nil
irb(main):043:0> puts(driver.html)
<html><head></head><body></body></html>
=> nil
I've searched and researched both Watir and Ghostdriver for documentation on anything like this but have found very little and nothing that could help me.
Any assistance will be appreciated,
mpozos
I'm facing same problem through launching watir / phantomjs on https page, with same result
<html><head></head><body></body></html>
So I tried with mechanize to bypass it, but I was facing another problem ..
It was due to ssl certificate. I solve it adding ssl version and 'do not take account of ssl error' in the new instance .. But I still need to solve the main watir problem..
I've found following informations that I will test tonight..
first one, include more informations when launching phantomjs :
switches = ['--proxy=69.106.88.7:60199', '--proxy-auth=username:password123']
browser = Watir::Browser.new :phantomjs, :args => switches
second, phantomjs usage :
Usage: phantomjs [options] script.[js|coffee] [script argument [script argument ...]]
Options:
--load-images=[yes|no] Load all inlined images (default is 'yes').
--load-plugins=[yes|no] Load all plugins (i.e. 'Flash', 'Silverlight', ...) (default is 'no').
--proxy=address:port Set the network proxy.
--disk-cache=[yes|no] Enable disk cache (at desktop services cache storage location, default is 'no').
--ignore-ssl-errors=[yes|no] Ignore SSL errors (i.e. expired or self-signed certificate errors).
so I think to test that solution :
switches = ['--ignore-ssl-errors=yes']
browser = Watir::Browser.new :phantomjs, :args => switches
I will publish results then
edit : I didn't succes with this solution .. I go watir headless directly .. hope this help
I try to put google calendar in a webkit window as wallpaper.
The python working script looks like :
#!/usr/bin/python2 -u
# -*- coding: iso8859-15 -*-
display_UI = True
email = "xxxx#gmail.com"
passwd = "xxxxxxxx"
useragent = "Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
import spynner
browser = spynner.Browser(
debug_level=spynner.WARNING,
user_agent = useragent
)
browser.create_webview(display_UI)
browser.webview.setWindowTitle('Gcalendar')
browser.webview.showMaximized()
browser.load("https://accounts.google.com/ServiceLogin?service=cl&passive=1209600&continue=https://www.google.com/calendar/render&followup=http://www.google.com/calendar&scc=1")
browser.fill("input[name=Email]", email)
browser.fill("input[name=Passwd]", passwd)
browser.click("input[name=signIn]")
browser.wait_load()
browser.load("https://www.google.com/calendar/render?pli=1")
browser.wait_load()
# vim:ts=4:sw=4
What I would like to do now, is to programmatically put this window as a wallpaper :
skip taskbar
skip pager
full screen (DONE with spynner module)
if I hide all applications, the window should stay like any wallpapers.
What I tried without sucess
kde advanced settings on application name
xwinwrap
You can take a screenshot of the page, save it somewhere and then launch a command that changes the background.
image = spynner.QImage(browser.webpage.viewportSize(), spynner.QImage.Format_ARGB32)
painter = spynner.QPainter(image)
browser.webpage.mainFrame().render(painter)
painter.end()
image.save("/path/to/img/gcscreen.png")
Then use the subprocess module to call a command that changes the wallpaper from terminal. A google search resulted with this for a Gnome ubuntu. I'm sure you can also find a similar one for KDE if you like.