Skip to content

Commit 6fef480

Browse files
committed
Check Linux and MacOS assemblie files execution and fix them if incorrect
Check Linux and MacOS assemblie files execution and fix them if incorrect
1 parent 4f00f9b commit 6fef480

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Selenium.psm1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ elseif($IsMacOS){
88
$AssembliesPath = "$PSScriptRoot/assemblies/macos"
99
}
1010

11+
# Grant Execution permission to assemblies on Linux and MacOS
12+
if($IsLinux -or $IsMacOS){
13+
# Check if powershell is NOT running as root
14+
$AssemblieFiles = Get-ChildItem -Path $AssembliesPath |Where-Object{$_.Name -eq 'chromedriver' -or $_.Name -eq 'geckodriver'}
15+
foreach($AssemblieFile in $AssemblieFiles){
16+
if($IsLinux){
17+
$FileMod = stat -c "%a" $AssemblieFile.fullname
18+
}
19+
elseif($IsMacOS){
20+
$FileMod = /usr/bin/stat -f "%A" $AssemblieFile.fullname
21+
}
22+
23+
if($FileMod[2] -ne '5' -and $FileMod[2] -ne '7' ){
24+
Write-Host "Granting $($AssemblieFile.fullname) Execution Permissions ..."
25+
chmod +x $AssemblieFile.fullname
26+
}
27+
}
28+
}
29+
1130
function Start-SeChrome {
1231
Param(
1332
[Parameter(Mandatory = $false)]

0 commit comments

Comments
 (0)