automation of ubuntu terminal and commands using selenium python - python-3.x

Can someone give me a code where I can automate.
Open the linux terminal using Ctrl+ALT+T.
Run small terminal commands using python and selenium .
I am a beginner and I want to know If i can do the above things using automation or Is there another way?

Related

Execute python executable and script inlucing full path

Im trying to create a python script with executes a series of python and sql scripts.
Some need to be executed using one python executable and some using another.
I've tried
from subprocess import call
call([r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
And
call([r"cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3", "pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
But the script isnt being executed.
I think the problem might be "How to execute an .exe file in windows terminal including full path to it"?
Please check my code. It is working well in my side.
from subprocess import call
call([r"C:\Python38\python.exe", r"E:\python\hello.py"])
As i think, the problem is that you use pythonw.exe.
if you use pythonw.exe, you can see any log in terminal.
Pythonw is useful for running script with GUI.

Unable to run Python files in terminal of VSC

i have installed VSC and set up the necessary dependencies for python.
Using a simple hello world example, i can run the file using run and debug option.
I can also run it by manually typing python hello.py in the terminal.
However, when i use the run button (top right hand corner), i get an error.
Can i check how to solve this?
Thank you.

How to convert a selenium webscraping script to exe file?

I've created a script using selenium and chromedriver on pycharm that works absolutely fine. I want to create an exe of that script so that I can run it on other PCs without installing python or the other dependencies. I've tried using pyinstaller but it is not working. Can someone guide me how can I convert that script into exe.
Thanks!!!
You are getting any error ? as pyinstaller is the best option to turn your script in to executables.

Python - execute sequential commands in same windows command prompt

I am very new to Python (been learning for a few days) . Can anyone help me with the following issue please?
I am trying to write a program to automate the testing of built in commands of a product which is installed on windows and linux.
Before any of the commands can run, the profile needs to be set using profile.cmd.
The commands ( command1.cmd, command2.cmd etc) then need to run in the same windows command prompt as profile.cmd as they rely on the environment which this sets.
The problem I find is that after profile.cmd has been run, python closes the windows command prompt and opens a new one for command1.cmd.
command1.cmd therefore fails to run properly as it is in a new command prompt which has not had the environment set by profile.cmd.
My code is shown below. I am currently testing on windows but will also need to test on linux.
Any suggestions would be much appreciated. Thanks - Kevin
import subprocess
rc = subprocess.run (["profile.cmd"],stdout=subprocess.PIPE)
print(rc.stdout.decode("ascii"))
rc = subprocess.run (["command1.cmd"],stdout=subprocess.PIPE)
print(rc.stdout.decode("ascii"))
rc = subprocess.run (["command2.cmd"],stdout=subprocess.PIPE)
print(rc.stdout.decode("ascii"))
rc = subprocess.run (["command3.cmd"],stdout=subprocess.PIPE)
print(rc.stdout.decode("ascii"))

Unable to run Selenium with htmlSuite on Linux with no GUI

I've created a very basic test using Selenium IDE and converted it into an HTML suite. I've setup a VM running CentOS 5.5 to perform Selenium tests.
When I try to use this command,
java -jar selenium-server-standalone-2.14.0.jar -multiwindow -htmlSuite "*firefox" "http://www.example.com" "login-test-suite.html" "sel-results.html"
I receive the following output with an exception http://pastie.org/2956400
Someone told me that Selenium is not able to find firefox in /usr/lib/firefox and that was correct, so I created a symlink
ln -s /usr/lib64/firefox-3.6 /usr/lib/firefox
But still getting the same error. I don't know how to create a profile in firefox via cli as I'm using SSH. My initial thought was Selenium should create a profile itself and if it can't, then definitely something is wrong.
I'll proceed to develop Selenium test in Python only when I get the simple htmlSuite test running.
I think suite file of your scripts folder, needs to be given folder permission to access by selenium. Hope we can give it in unix. Try to give the permission and try to run one more time. Hope this will help you.
Regards,
Neel

Resources