I'm trying to run a simple demo with Selenium in a bash script on macOS. The script is here:
#!/usr/bin/env bash
source ./selenium.sh
main() {
# Open the URL
navigate_to 'https://www.google.com'
# Get the search box
local searchBox=$(find_element 'name' 'q')
# send keys
send_keys $searchBox "panda\n"
}
main
The error is: line 2: ./selenium.sh: No such file or directory
I installed Selenium and wrote it to the project directory with NuGet Package Manager in Visual Studio Code so I have no idea why this script cannot find the file or directory for selenium.sh
I tried running the script from Visual Studio code and I tried running it from a zsh terminal but in both cases the same output appeared. It seems to have trouble finding selenium packages but it shouldn't because I successfully wrote the Selenium Web Driver with NuGet: Add Package
NuGet has installed the packages in ~/.nuget/packages
unless you have changed the configuration, therefore
#!/usr/bin/env bash
source ~/.nuget/packages/selenium/selenium.sh
main() {
# Open the URL
navigate_to 'https://www.google.com'
# Get the search box
local searchBox=$(find_element 'name' 'q')
# send keys
send_keys $searchBox "panda\n"
}
main
should work assuming selenium package was installed under that directory and selenium.sh
exists, does what you think it does, etc.
And as the comment recommends, if you are planning to use selenium outside of VSC, there are better ways.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.