zoom out firefox 52 on redhat 6.8 using selenium python 3.4 - python-3.x

I have redhat 6.8 where firefox is 52.8 esr and python is 3.4 and geckodriver is 18
My requirement is to zoom out the browser and take a screenshot of the required part of the webpage.
I tried below methods:
browser.execute_script("$('#values').css('zoom', 5);") ( This didnt work )
driver.execute_script("document.body.style.zoom = '200%'") ( This is applicable only for chrome )
element.send_keys(Keys.CONTROL + "-") ( This didnt work )
Below two methods I'm not getting appropriate results
driver.execute_script('document.body.style.MozTransform = "scale(0.8)";')
driver.execute_script('document.body.style.MozTransformOrigin="3 4";')
Below worked on MAC with firefox 52.8, but not working on redhat 6.8 with firefox 52.8 geckodriver is 18
element = driver.find_element_by_class_name('col-10')
location = element.location
size = element.size
png = driver.get_screenshot_as_png() # saves screenshot of entire page
im = Image.open(BytesIO(png)) # uses PIL library to open image in memory
left = location['x']
top = location['y']
right = location['x'] + size['width']
bottom = location['y'] + size['height']
im = im.crop((left, top, 2000, 2900)) # defines crop points
im.save('screen.png')
Note: Using firefox 52.8 esr because on redhat 6.8 we cannot upgrade to latest firefox and cant install chrome
Please help me to resolve the issue. I almost google search couldn't find an appropriate solution. Thanks in advance.

Related

\DeclareSymbolFont Not working with Ankiweb app

I am attempting to use math symbols that don't exist by default as part of existing packages in Options for notes (eg. amsmath). I tested the below code in TeXworks (pdfLaTeX) with no issues.
\DeclareSymbolFont{matha}{OML}{txmi}{m}{it}% txfonts
\DeclareMathSymbol{\varv}{\mathord}{matha}{118}
...
$ \varv = 0 $
Upon adding the \DeclareSymbolFont... and \DeclareMathSymbol... lines to
Tools => Manage Note Types => Options, and inserting the lines before \begin{document}, I tried below lines in Ankiweb app Card
\( \varv = 0 \) or [$] \varv = 0 [/$],
but ankiweb app doesnt convert this to the right symbol as it does with TeXworks
Is there something I need to do specifically? Or is the above steps not allowed in Ankiweb app.
Ankiweb app details:
Version ⁨2.1.54 (b6a7760c)⁩
Python 3.9.7 Qt 5.15.2 PyQt 5.15.5

jaydebeapi connection terminates without any exception or error | unable to investigate further

I followed the usage steps as per the example, after the second step of defining "conn" the script terminates and comes back to the command line without raising any errors o warnings or exception.
I am not able to identify what went wrong, has anyone faced this issue with jaydebeapi?
Sharing the libraries/environment details I am using and screenshot.
Example:
import jaydebeapi
conn = jaydebeapi.connect("org.hsqldb.jdbcDriver",
... "jdbc:hsqldb:mem:.",
... ["SA", ""],
... "/path/to/hsqldb.jar",) --------my script terminates at this step
curs = conn.cursor()
Environment:
Windows 10 64bit
Python 3.7.4
JayDeBeApi==1.1.1
JPype1==0.6.3
sasl==0.2.1
thrift==0.10.0
thrift-sasl==0.3.0
Jar = hive-jdbc-1.2.1-standalone.jar
Resolution is appreciated.
Are you using same (i.e. 64 bit) versions of programms? Reinstallation from python 32 to python 64 helped me with the same problem.

Python Windows 10 64bit - FFMPEG for trackpy

Similar problem to 'Python Moviepy installation problems (windows 7x64)' except the solution provided did not work.
I have windows 10, 64bit. Every time I attempt to run the following line of code:
frames = pims.Video('exp9_short.avi')
I get the blue Windows 10 error: This app can't run on your PC
as well as the Python error:
OSError: Could not load meta information
=== stderr ===
Access is denied.
I have tried multiple versions from 'https://ffmpeg.zeranoe.com/builds/' to no avail.
I don't know if other image processing tools will work with trackpy, or if there are any alternatives to trackpy.
I would really appreciate some advice.
I solved this problem by processing each image with OpenCV2
vid0 = cv2.VideoCapture('exp9_short.avi')
numfr = int(vid0.get(cv2.CAP_PROP_FRAME_COUNT))
for n1 in range(0,numfr-1):
success,img = vid0.read(n1) #read video frame by frame
if n1==0:
h, w, cols = img.shape #image size
fr=np.zeros([h,w,3,numfr-1]) #frames
frgr=np.zeros([h,w,numfr-1]) #grayscale fr
frgrbi=frgr #binarized frgr
fr[:,:,:,n1]=img
frgr[:,:,n1]=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

How to suppress console error/warning/info messages when executing selenium python scripts using chrome canary

I am running python script (complete script link below) for selenium test using Chrome Canary. The test seems to be running fine, however, there are lots of error/warning/info messages displayed on the console.
Is there a way to suppress these messages? I have tried:
chrome_options.add_argument("--silent"), but does not help. I am not able to find the right solution. Appreciate any help.
Python script : Example script provided here
Python: 3.6.3
Selenium: 3.6.0
Chrome Canary: 63.0.3239.5 (64 bit)
ChromeDriver : 2.33
Try options.add_argument('log-level=3').
log-level:
Sets the minimum log level.
Valid values are from 0 to 3:
INFO = 0,
WARNING = 1,
LOG_ERROR = 2,
LOG_FATAL = 3.
default is 0.
If "--log-level" doesn't work for you (as of 75.0.3770.100 it didn't for me), this should:
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path='<path-to-chrome>', options=options)
See https://bugs.chromium.org/p/chromedriver/issues/detail?id=2907#c3
Code copied from Python selenium: DevTools listening on ws://127.0.0.1
Works for me in Python/Chrome...
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--log-level=3')
You can take help of below link.
List of Chromium Command Line Switches
"--log-level" sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.
I have just tested this one, it works for me (C#):
ChromeOptions options = new ChromeOptions();
options.AddArguments("--headless", "--log-level=3");
RemoteWebDriver driver = new ChromeDriver(options);
import os
os.environ['WDM_LOG_LEVEL'] = '0'
That code hides the console output for from webdriver_manager.chrome import ChromeDriverManager console outputs

Selenium webdriver issue with file paths

I'm having an issue with Selenium standalone webdriver used with webdriver-manager npm module. I'm using the Firefox Gecko driver. I need to select a file from an HTML file input component. When I try this on my local machine or on BrowserStack I get the error:
"WebDriverError: File not found: /Users/christophergrigg/a.pdf"
const requestFile = By.id('requestFile');
driver.wait(until.elementLocated(requestFile));
const requestFileEl = driver.findElement(requestFile);
driver.wait(until.elementIsVisible(requestFileEl), TIMEOUT).click();
requestFileEl.sendKeys('/Users/christophergrigg/a.pdf');
requestFileEl.sendKeys(webdriver.Key.ENTER);
On Browser stack I'm using this path:
requestFileEl.sendKeys('C:\\Desktop\\documents\\pdf-sample2.pdf'); // Windows 7 / 8 / 8.1
You need to provide the full path of the file. And if the file is not present on the machine running the remote instance, you'll also have to set the file detector to automatically upload the file.
On mac OS X:
var remote = require('selenium-webdriver/remote');
driver.setFileDetector(new remote.FileDetector);
driver.sendKeys('/Users/christophergrigg/Desktop/a.pdf');
, or Windows:
var remote = require('selenium-webdriver/remote');
driver.setFileDetector(new remote.FileDetector);
driver.sendKeys('C:\\Users\\christophergrigg\\Desktop\\a.pdf');

Resources