Why can I not do the following:
String xpathString = "\"(//input[#name='FIN'])" + "[" + 3 + "]\"";
driver.findElement(By.xpath(xpathString)).click();
As I get the following error
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
However, the following does not cause an error and works fine
driver.findElement(By.xpath("(//input[#name='FIN'])[3]")).click();
The reason I want to use a stored string is that I want to use a loop to loop through the different instances and find the one that doesn't cause an error when clicked.
Any help appreciated.
yes, try by simply removing back-Slash following double quotes.
like this,
"(//input[#name='FIN'])["+3+"]"
or to make it dynamic,
"(//input[#name='FIN'])["+i+"]"
remove the quotes from the stored string!
Related
Here is the simple code
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("${str}");
I am expecting to see the value of str in logs but I am getting ${str}. I am validating it because I have to assign the current time to a variable and later want to use it in script. But I am not getting the value stored in str.
try as follows using vars.get:
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("str " + vars.get("str"));
I wouldn't recommend inlining functions and/or variables into Beanshell script as you may face syntax error issues, i.e. type mismatch if the value has quotation marks.
So either use log.info(vars.get("str")); or use Debug Sampler and View Results Tree listener combination to see JMeter variables values.
More information: How to Debug your Apache JMeter Script
I have an UPDATE pass through query saved in Access 2007. When I double-click on the pass through query it runs successfully. How can I get this query to run from VBA? I'd like it to run when my "splash screen" loads.
I'm currently using the following code:
CurrentDb.Execute "Q_UPDATE_PASSTHROUGH", dbSQLPassThrough
But I get the following message:
The pass-through query contains all the connection information and I've confirmed the SQL syntax is correct by running it multiple times, so not sure what I'm missing in my VBA call.
Use the QueryDef's Execute method:
CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute
I don't think you should need to explicitly include the dbSQLPassThrough option here, but you can try like this if you want it:
CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute dbSQLPassThrough
I recently ran into the same problem. While the above mentioned Execute method is working for most cases, some people (me included) experiencing a Run-time error '3001': Invalid Argument when using the parameter dbSQLPassThrough. This was also addressed in the answer above me and happens even in the simplest SQL-statements.
For those who are having the same problem, I recommend using the OpenQuery method as alternative.
A valid substitution for the following code
CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute
would be
DoCmd.OpenQuery "Q_UPDATE_PASSTHROUGH"
I know this thread is 4 years old, however, searching for a solution for the not working Execute method on Google brings you directly to this thread which is why I thought it would be useful to add an alternative solution which solved this problem for me.
I confirm that the QueryDef's Execute method is the recommended way to achieve your goal.
CurrentDb.QueryDefs("Q_UPDATE_PASSTHROUGH").Execute
However, I can point out that in a similar case with Access 2010, using dbSQLPassThrough for the Options parameter caused a Run-time error '3001': Invalid Argument.
I am trying to run a C# program to determine if a directory exists on multiple servers, so I need to run it as %system Variable%, rather than making a drive letter call, since not every server will have the same drive letter. This is what I have:
If My.Computer.FileSystem.DirectoryExists("D:\backup") Then
This code will work, as I define the drive
If My.Computer.FileSystem.DirectoryExists("%BCK_DRV%\backup") Then
This will not, I get my else error when running it. The %BCK_DRV% is defined in the environment variables, and I can navigate to the folder without issue using %BCK_DRV%\backup. Is there a special way to set and define a %drive% in C#?
Environment.GetEnvironmentVariable?
Code sample:
Dim backupDrive As String = Environment.GetEnvironmentVariable("BCK_DRV") & "\backup"
If My.Computer.FileSystem.DirectoryExists(backupDrive) Then
Try Environment.ExpandEnvironmentVariables():
string raw = #"%BCK_DRV%\backup" ;
string expanded = Environment.ExpandEnvironmentVariables( path_raw ) ;
Naturally, it's up to you to ensure that your process inherits the correct environment.
To expand "%BCK_DRV%\backup" to it's real value you need
Environment.ExpandEnvironmentVariables();
Example:
Environment.ExpandEnvironmentVariables("%winDir%\test")
will expand to "C:\Windows\test" (on my system).
I have an sql querying tool that is written in Haxe and im trying to add some sql comment support to the code. Currently if a user has any comments (single line or multi line) the query fails on the server side. Thus, im trying to write a simple method that takes the sql the user inputs and replaces any comments with a "". Here is method
static function removeComments(snippet: SqlSnippet): SqlSnippet {
var rComment: EReg = ~/(--[^\n]*)|(/\*[\w\W]*?(?=\*/)\*/)/;
var resultSql = rComment.replace(snippet.sql, "");
snippet.sql = resultSql;
return snippet;
}
My issue isnt with this method, but that neko wont compile it. When i try to compile this method i get this message:
src/skyview/SqlSnippetParser.hx:30: character 33 : Invalid character '\'
[Finished in 0.2s with exit code 1]
the '\' this message is refering to is the '\' im trying to use to escape the '*' metacharacter at the beginning of the 2nd set of "()"
Does anyone know why nako wont compile the "/*" in this EReg?
The problem is not \*. It is / needs to be escaped.
Try changing your EReg to ~/(--[^\n]*)|(\/\*[\w\W]*?(?=\*\/)\*\/)/.
I have a really long list of sql commands on a memo, when I try to execute it I get the following error:
Parameter object is improperly defined. Inconsistent or incomplete information was provided.
The code to execute it:
Query.SQL.Text := Memo1.Lines.Text;
Query.ExecSQL;
I have a vague idea that the error is caused due to the way the query content was added, so, here's how I'm doing it now:
1) Memo1.Lines.LoadFromFile('Patch.sql');
2) Proceed to the query commands
As you can see, the contents of the memo is loaded from a file. Is there any other way to successfully do this?
P.S.: I'm using Microsoft SQL 2008.
Thank you!
It looks like you're not using parameters, so set ParamCheck off
Query.ParamCheck := false;
If there is a colon ":" in a string in the SQL, the TADOQuery thinks it's a parameter