I've written a Powershell script to automate a Web UI test using IE. The script runs fine when I execute it from PowerShell. However, I have run into an obscure problem and that is when I run my Web UI test script from another powershell script, it fails. I tried to debug it and found that it fails on the following line.
$button = $ie.Document.getElementsByTagName("button")
$button.Item().Click() # $button.Item() evaluates to null when the script is executed from another script.
Can anyone help me figure this out? It appears that when I run the script, the script has no issues locating the element, but when it is run from another script the element I am looking for cannot be located.
EDIT
I get the same error when I run the PS script through Task Scheduler. The script only works when I invoke it directly. If I invoke via another script/program, it doesn't work.
Related
Hi All I am tying to setup a RestAPI pipeline in aws codebuild. I have custom Newman docker. I have a build command that will failure but I want to execute the rest of the commands as well. but shell stops executions other commands when the Newman command fails. how to execute other commands in yml file.
One simple way would be:
You can create a custom shell script (mycommand.sh) with your command that can cause error inside a try catch statement (so that it will not result in an error)
In your Code build's yml file under commands section, just execute the ./mycommand.sh
Source:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-cmd.html
It's not a problem and actually is a nice side affect, but it is confusing me.
When I run the test suite via the command line I see IE pop up and the test run.
When I run it with the exact same arguments from the Task Schedular though it doesn't display IE. The test seems to run correctly (I'm getting the expected TestResults.xml so it all looks OK.
Why's this happening though?
The command is:
"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "Path_to_test_assembly"
P.S. I'm using the .NET version of Selenium with the IE web driver.
Ok, it seems that the problem is with your access to remote machine. Your IE test are running as a background process on that machine, or running on wrong sessionID. It means that there could be more users/accounts, and your test is running on wrong one.
I'm not sure how exactly are you running this, but you could check your session ID's by typing qwinsta in command line on that machine.
If you want it to run properly you should pass this sessionID as a parameter when connecting to remote desktop, for example, if using psexec and your sessionID is 2 than you pass "-i 2" when starting it. It means that it will interact on user with sessionID 2 on that machine.
I have a simple (test) Powershell script, it creates an empty file. The script runs fine executed manually in Powershell. However it does nothing when executed in SSIS.
I've tried executing it in an Execute Process task and also in a VB.Net Script task.
Both times Poweshell seems to open (I see the screen come up and close quickly), however the file that the script tries to create doesn't get created.
Any ideas how to troubleshoot this would be appreciated!
Thank you!
Adding -ExecutionPolicy ByPass is what made it work. So now what I am passing is:
-ExecutionPolicy ByPass -file "\\SERVER\Share\Script.ps1"
This is where I got this tip - http://www.sqlservercentral.com/Forums/Topic1714552-147-1.aspx
After I added this, Read-Host started working also and paused the execution of the script.
I'm writing a script for Illustrator CS6 in ExtendScript. At the end of my script, I want to spawn a task (a second script, in Ruby) using File.execute(). However, it's not working. And I'm at a loss as how to debug the problem -- how can I figure out why this isn't working?
Here's the end of my ExtendScript file:
// Do a bunch of other work, then:
var rubyFile = new File(scriptFolder + 'BuildHtmlWalkthrough.rb');
alert(rubyFile.exists);
var result = rubyFile.execute();
alert(result);
Both rubyFile.exists and result are always true, indicating that the script launched OK. But the script does not appear to run, at all. I've tried the following diagnostics:
The Ruby script does successfully run from the command line. The script's permissions are -rwxr-xr-x
I added a call to system("touch /blah/blah/blah") as the very first line of the Ruby script. The file does not get touched.
I thought maybe the ExtendScript process was terminating before the Ruby script could run, so I added a long for loop after rubyFile.execute(). Spinning for > 30 seconds did not help.
What can I do to debug, or solve, this problem?
I'm on MacOS X v10.9.1. And for reference, this is the documentation for File.execute():
File.execute (): Boolean
Core JavaScript Classes
Executes or opens
this file using the appropriate application, as if it had been
double-clicked in a file browser. You can use this method to run
scripts, launch applications, and so on. Returns true immediately if
the application launch was successful.
It's probably doing the "opens this file using the appropriate application" instead of executing, and returns true because the file successfully opens (or is already open in its associated app). If I have a python script and do
f= new File("~/Documents/misc_scripts/getpixelrgb.py");
f.execute();
, it opens it in my script editor, even if the file's execute flags are set.
I'm on OSX, btw
In After Effects, there is system.callSystem() to execute command line commands, but I'm afraid that is absent in Illustrator (I'm assuming you're doing this for Illustrator because of the tag). Are you on OSX or Windows? There are ways around this, by making an executable .app (OSX) or .exe (Win) and calling that with execute(). If I were doing this, I'm on OSX and I'd make an AppleScript app that does 'do shell script' to make the ruby system call. On Windows, it's different. One solution you might like if you're on windows: ocra, which is ruby-specific (http://ocra.rubyforge.org/). It may be possible to run a .bat file on Windows that calls the ruby script, but I'm not sure.
[edit!]
Terribly sorry for the extraneous Windows info (for someone else, I guess). Just saw your note about being on OSX. So you might want to use the AppleScript solution.
[edit again]
So, if my ruby script ("test.rb") is:
#!/usr/bin/env ruby
print "Hello"
and my AppleScript is:
do shell script "cd /testing_folder/; ruby test.rb"
Then I get "Hello" returned in AppleScript, but ExtendScript will just return true.
Hello people.
I'm using Jenkins as CI server and I need to run some performance test using Jmeter. I've setup the plugin and configured my workspace and everything works ok, but I have to do some steps manually and I want a bit more of "automation".
Currently i have some small programs in a remote server. These programs make some specific validations, for instance (just to explain): validates e-mail addresses, phone numbers, etc.
So, before I run the build in jenkins, I have to manually start the program (file.sh) I want:
I have to use putty (or any othe ssh client) to conect to the server and then run, for instance, the command
./email_validation.sh
And the Jmeter test runs in a correct way, and when the test is done I have to manually "shut down" the program I started. But what I want is trying to start the program I need in Jenkins configuration (not manually outside Jenkins, but in "execute shell" or "execute remote shell using ssh" build step).
I have tried to start it, but it get stuck, because when Jenkins build finds the command
./email_validation.sh
the build stops, it waits for the command to finish and then it will continue the other build steps, but obviously, I need this step not to finish until the test is executed.
Is there a way to achieve this? Thanks
Run your command as a background process by adding the & symbol at the end of the command and use the nohup command in case the parent process gets a hangup signal, e.g.
nohup /path/to/email_validation.sh &
If the script produces any output, it will go by default to the file nohup.out in the current directory when the script was launched.
You can kill the process at the end of the build by running:
pkill email_validation.sh