Skip to content

Commit

Permalink
hope
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Apr 20, 2024
1 parent a513467 commit 98c4347
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
39 changes: 36 additions & 3 deletions py/selenium/service_builder/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import json
import platform
import os
import sys
import semver

from unittest import TestCase

from selenium import webdriver
Expand All @@ -15,15 +19,44 @@ class TestWindow(TestCase):
Setup Selenium driver.
'''
def setUp(self):

with open('./package.json') as f:
pkg = json.load(f)

dependencies = pkg.get('devDependencies', {})
version = dependencies['nw']
version = semver.VersionInfo.parse(version[1:])
version = f"{version.major}.{version.minor}.{version.patch}"

host_platform = ''
if (sys.platform == 'linux'):
host_platform = 'linux'
if (sys.platform == 'win32'):
host_platform = 'win'
if (sys.platform == 'darwin'):
host_platform = 'osx'

host_arch = ''
if (platform.machine() == 'x86_64' or platform.machine() == 'AMD64'):
host_arch = 'x64'
if (platform.machine() == 'i686'):
host_arch = 'ia32'
if (platform.machine() == 'arm64'):
host_arch = 'arm64'

nwjs_dir = f"nwjs-sdk-v{version}-{host_platform}-{host_arch}"
# We are using the nw node module to download NW.js
# Change the path as necessary
# "./node_modules/nw/nwjs/chromedriver"
chromedriver_path = Path('node_modules', 'nw', 'nwjs', 'chromedriver')

chromedriver_path = Path('node_modules', 'nw', nwjs_dir, 'chromedriver')
chromedriver_path = str(chromedriver_path.resolve())

if sys.platform == "win":
if sys.platform == "win32":
chromedriver_path += ".exe"

print(platform.machine())
print(chromedriver_path)

options = webdriver.ChromeOptions()
# File path to NW.js project
options.add_argument("nwapp=" + str(Path('py', 'selenium', 'service_builder').resolve()))
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
selenium == 4.16.0
semver == 3.0.2
pytest == 7.4.3
urllib3 == 2.2.1

0 comments on commit 98c4347

Please sign in to comment.