Python Selenium: XPath changes the encoding of my variables - python-2.7

I has this code that searches through text by XPath. The problem is that the searched text may contain Latin characters like ñor í.
I encoded it and when I print it, it shows perfectly, but when I use the XPath the encoding changes, and obviously it can't be found.
The decoded var prints well:
nombre_act = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
nombre_act = nombre_act.decode("utf8")
nombre_contrato = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato.decode("utf8")
print nombre_contrato
xpath = "//select[#name='"+nombre_act+"']/option[text()='"+nombre_contrato+"']"
print xpath
hotel_sel = driver.find_element_by_xpath(xpath).click()

Your code trials were near perfect. However I feel you don't need to change through encoding/decoding unless you want to print the characters to the console as follows:
nombre_act_actual = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
#nombre_act = nombre_act_actual.encode("utf-8")
nombre_contrato_actual = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato_actual.encode("utf-8") #required as you need to print to the console
print nombre_contrato
xpath = "//select[#name='"+nombre_act_actual+"']/option[text()='"+nombre_contrato_actual+"']"
hotel_sel = driver.find_element_by_xpath(xpath).click()
However, your another issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.41
Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v67-69
You are using chrome=70.0
Release Notes of ChromeDriver v2.44 clearly mentions the following :
Supports Chrome v69-71
So there is a clear mismatch between ChromeDriver v2.41 and the Chrome Browser v70.0
Solution
Upgrade ChromeDriver to current ChromeDriver v2.44 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.44 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test.

Related

set_glue_version exception after upgrading aws-glue-sessions

Using interactive Glue Sessions in a Jupyter Notebook was working correctly with the aws-glue-sessions package version 0.32 installed. After upgrading with pip3 install --upgrade jupyter boto3 aws-glue-sessions to version 0.35, the kernel would not start. Gave an error message in GlueKernel.py line 443 in set_glue_version Exception: Valid Glue versions are {'3.0', '2,0} and the Kernel won't start.
Reverting to version 0.32 resolves the issue. Tried installing 0.35, 0.34, 0.33 and get the error, which makes me think it's something I'm doing wrong or don't understand and not something in the product. Is there anything additional I need to do to upgrade the version of the aws-glue-sessions?
Obviously this is not a good workaround - but it worked for me.
I went into the file GlueKernel.py in the directory: \site-packages\aws_glue_interactive_sessions_kernel\glue_pyspark
and hard-coded the 2nd line of this function to set the version to "3.0"
I'm on windows
def set_glue_version(self, glue_version):
glue_version = str("3.0")
if glue_version not in VALID_GLUE_VERSIONS:
raise Exception(f"Valid Glue versions are {VALID_GLUE_VERSIONS}")
self.glue_version = glue_version
I am a bit lost here as well -- and confused. I will add that I am a python newbie. I am running the whole thing on Windows. AWS has an article that describes the installation. So, I am assuming it's supported. I get the same error as #theOtherOne.
line 443 in set_glue_version Exception: Valid Glue versions are {'3.0', '2,0}
I checked GlueKernel.py of glue_pyspark, and found this code:
def _retrieve_os_env_variable(self, key):
_, output = subprocess.getstatusoutput(f"echo ${key}")
return output or os.environ.get(key)
When I run the code below manually, I get $GLUE_VERSION as final result. That obviously doesn't match '2.0' or '3.0'. The command for retrieving environment variables on Windows is a different one. If my understanding is correct, then this whole thing will never work on Windows. Maybe I am the only one who wants to run it on Windows and no one else cares? I got it to work on WSL, but still. I lost quite some time to fix something that cannot be fixed (or can it?)
import subprocess
import os
_, output = subprocess.getstatusoutput(f"echo $GLUE_VERSION")
osoutput = os.environ.get("GLUE_VERSION")
print(output) #$GLUE_VERSION
print (osoutput) #'3.0'
print(output or osoutput) #$GLUE_VERSION
enter image description here
So the issue seems to be that GLUE_VERSION is not set in the environment variables. Once this is set - it works

Why cant I use a Character length more than 65535 RPGIV

I red the following article and it seems like I should be able to define a variable of type varying that's size limit will be 16mb instead of 65535 characters.
http://www.mcpressonline.com/programming/rpg/v6r1-rpg-enhancements.html
This forum post suggests that it is posible to do this in V6.1.
http://www.code400.com/forum/forum/iseries-programming-languages/rpg-rpgle/11426-character-string-max-length
D BigVarying S a Len(25000000) Varying(4)
When I try to implement this I get the following errors and it seems like I cannot use Len(25000000) Varying(4)
Maybe I don't understand what exactly is meant by V6.1 but I checked on the Green screen using the command DSPSFWRSC and get the following Release V6R1..
I also checked by using I systems navigator and I checked the servers properties and it is : i5/OS version Version 6 Release 1 Modification 0.
The IDE I use to compile is IBM Websphere development studio
Version: 7.0.0
Build id: 20070202_0030
Trying to compile a RPGLE function.
Am I checking the correct version or is there a RPG version and how do you check it.
can you please help me out of my confusion.
V6.1 is your operating system version and you can refer to the V6.1 ILE RPG Language Reference here to see if it's possible. I think what you're looking for is on page 185.
I've just tested this in 7.2 and I am not getting the same errors.
D BigVarying S a Len(25000000) Varying(4)
RNF0501E Length of character item exceeds 16773104; length defaults to 16773104.
RNF0231E Length of varying length character item exceeds 16773100; length defaults to 16773100.
//Dcl-S BigVarying Varchar(25000000);
BigVarying = 'Hello world';
Return;
So, as the (duplicate) error mentions
Length of character item exceeds 16773104; length defaults to 16773104.
If you'd like a bigger length you'll need to update to a newer version of IBM i - but the max length is also 16773104, meaning 25000000 is invalid.
While RPGLE supports 16MB variables from 6.1 forward and you are on 6.1..
You have two problems:
25000000 (23.8MB) is bigger than 16773104 (~16MB)
Websphere Development Studio v7 (WDSc) is older than IBM i 6.1 (your build date is 2007, the article you're referencing came out in 2008). So your IDE doesn't recognize the new keywords and new max size.
Problem #2 isn't a deal breaker, you can simply ignore the errors in the IDE and compile on ther server successfully. If you were using the green screen editor SEU, you'd have to do the same as IBM stopped enhancing SEU at 6.1.

How to enumerate the installed StoreApps and their ID in Windows 8 and 10

What I want to get is the AppUserModelId of all installed StoreApp applications, so that I can pass it to IApplicationActivationManager->ActivateApplication.
In Windows 8 it was stored in the Registry, but in Windows 10 it is not anymore.
There are a lot of questions about this in internet but even after days of searching I could not find a satisfying solution.
What I have so far is the following:
I create an instance of IPackageManager,
I call FindPackagesByUserSecurityId() with the SID of the current user,
I iterate through the returned collection
I get an IPackage interface
From that I get an IPackageId interface,
Then I call IPackageId->get_FamilyName()
With that I have for example on Windows 10 for the Windows Calculator the string "Microsoft.WindowsCalculator_8wekyb3d8bbwe".
When I append to this string an "!App" I have the complete AppUserModelId to start the Windows Calculator: "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
But not all applications use an "!App" behind the FamilyName.
For example Spartan uses the AppUserModelId
"Microsoft.Windows.Spartan_cw5n1h2txyewy!Microsoft.Spartan.Spartan" which does not end with "!App". And when I replace "!Microsoft.Spartan.Spartan" with "!App" it will not start -> "This app does not support the contract specified".
So my question is where do I get the last missing part from?
I found a PowerShell code in internet (http://poshcode.org/5702) that seems to do something very similar:
Get-AppXPackage $PackageName -pv Package |
Get-AppxPackageManifest | % {
foreach($Application in $_.Package.Applications.Application) {
if($Application.Id -like $AppId) {
if($Protocol -and !($Application.Extensions.Extension.Protocol.Name | ? { ($_ + "://") -match (($Protocol -replace '\*','.*') + "(://)?") })) {
continue
}
[PSCustomObject]#{
# Notice the secret magic property:
PSTypeName = "Microsoft.Windows.Appx.Application"
AppUserModelId = $Package.PackageFamilyName + "!" + $Application.Id
}
}
}
}
I really don't understand this cryptic PowerShell stuff, but one line seems interesting to me:
foreach($Application in $_.Package.Applications.Application)
This seems to enumerate Applications in a Package.
A comment in the same PowerShell code says:
# The full AppUserModelId is composed of the package name,
the publisher id, and the app id, such as
Microsoft.ZuneMusic_8wekyb3d8bbwe!Microsoft.ZuneMusic
so what is missing is the $Application.Id.
If I could get an IAppInfo interface anyhow I could call IAppInfo->get_Id() and I would be ready.
But I don't know how to get this from an IPackage in C++.
Incredible that nobody has an idea!
This shows how Microsoft makes us life hard.
Such a universal task like enumerating the installed StoreApps with their AppUserModelId requires a cientific research department.
I finally came to a solution that works perfectly on Windows 8 and Windows 10. But a lot of code is required.
It seems that Windows does not hold the Application ID's in memory and there is no API to determine them directly. I studied all header files in the Windows 10 SDK and could not find a corresponding interface useful for that task.
But I found out how to get them. I continue after the 6 steps in my question:
call IPackage->get_InstalledLocation() which returns an IStorageFolder.
QueryInterface for IStorageItem
call IStorageItem->get_Path()
Now you have the path were the App is installed. Windows 10 uses two base folders:
C:\Program Files\WindowsApps
C:\Windows\SystemApps
and several others like
C:\Windows\vpnplugins
C:\Windows\devicesflow
C:\Windows\MicracastView
C:\Windows\PrintDialog
C:\Windows\PrintDialog3D
C:\Windows\WinStore
In the returned folder path you will find a file "AppxManifest.xml".
This file looks like:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns=".....">
......
......
<Applications>
<Application Id="microsoft.windowslive.mail" Executable="HxMail.exe" EntryPoint="Executable">
......
......
</Application>
<Application Id="microsoft.windowslive.calendar" Executable="HxCalendarAppImm.exe" EntryPoint="Executable">
......
......
</Application>
</Applications>
</Package>
And voilà, there they are. This package has two application ID's: "microsoft.windowslive.mail" and "microsoft.windowslive.calendar".
Then you take the package's FamilyName from step 6 append an "!" and append this ID and you are done.
This package can be started with IApplicationActivationManager->ActivateApplication() using one of the AppUserModelId's:
"microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.calendar"
"microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"
Use PackageManager APIs to enumerate packages and GetPackageApplicationIds to enumerate applications in a package e.g. pseudo-code
FOREACH p IN PackageManager.FindPackagesForUserWithPackageTypes(null,
PackageType_Main|PackageType_Optional)
{
PACKAGE_INFO_REFERENCE pir
OpenPackageInfoByFullName(p.Id.FullName, 0, &pir)
UINT32 n=0
GetPackageApplicationIds(pir, &n, null, null)
BYTE* buffer = new BYTE[n]
UINT32 count=0
GetPackageApplicationIds(pir, &n, buffer, &count)
ClosePackageInfo(pir)
PCWSTR * applicationUserModelIds = reinterpret_cast<PCWSTR*>(buffer);
FOR (i=0; i<count; ++i)
{
PCWSTR applicationUserModelId = applicationUserModelIds[i]
}
delete [] buffer
}
See GetPackageApplicationIds() on MSDN for more details including working sample code
https://msdn.microsoft.com/en-us/library/windows/desktop/dn270603(v=vs.85).aspx

FFmpeg: Failed to create drawbox filter with max thickness

I've switched from FFmpeg version 1.2. to the last 2.5 release. After changing all deprecated methods I ran into a problem with a drawbox filter. In version 1.2 I could define a filled box with the following settings (see FFmpeg Filter Documentation):
strFilterDesc += "drawbox=x=0:y="+height+":w="+width+":h=50:color=0xeeeeee#0.4:t=max,
When I start the application, I receive the following errors:
[Parsed_drawbox_2 # 0x79e9a0] [Eval # 0x7fffb57f8e70] Undefined constant or missing '(' in 'max'
[Parsed_drawbox_2 # 0x75f0a0] Error when evaluating the expression 'max'.
[Parsed_drawtext_1 # 0x759be0] Failed to configure input pad on Parsed_drawbox_2
Can someone give me a hint what I'm doing wrong here? Even with the example of the documentation the same error occurs. Is there an other way to create a filled box?
Edit:
Here's the content of stfFilterDesc:
drawtext=fontfile=./fonts/truetype/freefont/HelveticaNeue.ttf: text='foo': x=5: y=5: shadowx=0: shadowy=0: fontsize=12: fontcolor=0xeeeeee#1.0: box=0: boxcolor=0xeeeeee#0.5, drawbox=x=0:y=490:w=960:h=50:color=0xeeeeee#0.4:t=max, drawtext=fontfile=./fonts/truetype/freefont/HelveticaNeue.ttf: text='foo': x=32:y=(h-text_h-25): fontsize=16: fontcolor=0x333333#1.0: box=0: boxcolor=0xeeeeee#0.4, drawtext=fontfile=./fonts/truetype/freefont/HelveticaNeue.ttf: text='foo': x=32:y=(h-text_h-10): fontsize=14: fontcolor=0x333333#1.0: box=0: boxcolor=0xeeeeee#0.4
You encountered a bug: #4332 – Expression 'max' no longer works with t option in drawbox.
This was fixed today (2015 March 2) with commit 047fd98:
commit 047fd986bf3641ad3dc137746097271c339ee5f0
Author: Michael Niedermayer
Date: Mon Mar 2 02:32:55 2015 +0100
avfilter/vf_drawbox: Fix handling of max values
Fixes Ticket4332
Signed-off-by: Michael Niedermayer
So you will need to compile or get a recent build to take advantage of this bug fix. The various static builds available via the FFmpeg download page are updated regularly.

Sending Fax via ColdFusion & VBScript Windows Server 2008

This is related to a previous thread I started, but it deals with a method that actually works.
I have created a VBScript that ColdFusion executes and sends a fax to a specific number. The following is the VBScript I wrote, taken from a Microsoft TechNet Site:
Set objFaxDocument = WScript.CreateObject("FAXCOMEX.FaxDocument")
Set objFaxServer = WScript.CreateObject("FAXCOMEX.FaxServer")
Dim JobID
objFaxServer.Connect("")
objFaxDocument.Body = "C:\*PATHNAME*\testfax.pdf"
objFaxDocument.DocumentName = "My First Fax"
objFaxDocument.Priority = "2"
objFaxDocument.Recipients.Add("8885551212")
objFaxDocument.AttachFaxToReceipt = True
objFaxDocument.CoverPageType = "1"
objFaxDocument.CoverPage = "generic"
objFaxDocument.Note = "Here is the info you requested"
objFaxDocument.ReceiptAddress = "test#test.com"
objFaxDocument.Subject = "Today's fax"
objFaxDocument.Sender.Title = "Mr."
objFaxDocument.Sender.Name = "Test Man"
objFaxDocument.Sender.City = "Test City"
objFaxDocument.Sender.State = "FL"
objFaxDocument.Sender.Company = "Test Company"
objFaxDocument.Sender.Country = "USA"
objFaxDocument.Sender.Email = "test#test.com"
JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
MsgBox("The Job ID is :" & JobID(0))
objFaxServer.Disconnect()
The following is the ColdFusion code I use to execute this vbscript:
<cfexecute name="C:\Windows\System32\cscript.exe"
arguments="C:\*SCRIPTPATH*\test.vbs">
</cfexecute>
On a machine that has Windows Server 2003, this successfully sent the document to the Windows Fax Service application, and stored the fax correctly in the outbox. However, when I attempted this on Windows Server 2008, it does not work. It should be noted that while the same version of ColdFusion (8) is being used, the 2008 machine is 64-bit while the 2003 is 32-bit.
This may have been answered elsewhere (if so please guide me) but I have had the hardest time with this and there are not many successful solutions out there for me to find. I know I'm missing something but I don't know what. Can anybody help?
This is difficult to answer that precisely because you don't quantify "does not work". In what way does it not work? Is there an error on the screen? Is there an error in the log files anywhere? Does the VBS get called, but does it then fail (it could be a vagary of how it's being called)?
That said, I suspect it's a case that the service account that CF is running under doesn't have permissions to access or execute the VBS, or some other resource the VBS uses.
If you login as the user CF uses, can you execute that statement from a command line?