Calling Function from another selenium file - selenium

I am trying to call a function from another file in selenium python. But when the call is sent from one to other file, instead of accessing only that certain function, the whole script will start running, until finished. Then the control will comeback to original file.

Related

LabVIEW Asynchronous call

I have two VIs. The first VI (AsynchronousCall.vi) performs an "asynchronous call." (see in the following picture)
The following VI (Test.vi) is started by the asynchronous call. (see in the following picture)
The first VI only iterates over an array and starts the Test.vi. An element from the array is passed. This element should then be used in Test.vi. However, the first entry from the array is not passed correctly after the first call.
It follows that my asynchronous program does not receive the correct input data.
Important: In order to recreate the Senario, the front panel of Test.vi can be opened first after the asynchronous call. Because when it's open, it works as intended!
The target/actual comparison is in the following list:
Target value
Asynchronous program should have "Test_0" as input parameter.
Asynchronous program should have "Test_1" as input parameter.
Asynchronous program should have "Test_2" as input parameter.
Asynchronous program should have "Test_3" as input parameter.
Actual value
Asynchronous program is "" (empty string) as input parameter.
Asynchronous program is "Test_1" as input parameter.
Asynchronous program is "Test_2" as input parameter.
Asynchronous program is "Test_3" as input parameter.
How can it be avoided that the string is empty the first time it is called?
The 32-bit version of LabView 2015 is used, but this Senerio also occurs with newer versions (32-Bit LabVIEW 2019)
When you call a VI asynchronously with the Front Panel closed, LabVIEW does not appear to update the values displayed in the controls - this makes sense from a resource perspective as why paint an update to a control that no one can see?
If you were to perform an operation on the passed value in your test VI - such as writing it to a file or some shared queue you should be able to verify that the correct value is indeed passed, just not displayed in control on the front panel. The one button dialog can also be used for debugging this but it might block the open VI reference call in the launcher VI and thus cause your launcher loop to stall. See this discussion on LAVA forums about the root loop and the built-in dialog windows.

Access WebView2 newly opened window

If I run window.open("url") it will open url in new popup window, even if it is Edge WebView2. It will just have default Windows title-bar, and read-only url bar. I need to open url from WebView exactly in new popup window, via window.open("url").
Is there any way to access that window from my program as far as original WebView2 child-window? By accessing I mean injecting scripts, and getting js-response after injecting.
Or, at least, perhaps there is way to open url with some pre-injected script, like window.open("http://google.com -javascript: alert(5)")?
Update
Found MSDN article, probably this is what do I need. Trying to understand that.
Yes, the ICoreWebView2::add_NewWindowRequested event lets you intercept WebView2 opening new windows.
If you do nothing in the event handler, or don't subscribe to the event, you'll get a new popup like you describe. In script the return value of window.open is connected up to the newly opened popup window. But in your native code you have no access to or control over the newly opened window.
Or you can set the Handled property to true on the NewWindowRequested event's args, and no new window will be created. This is useful if you want to prevent opening windows or if you want to send new window opens to the default browser or somewhere else. In script the return value of window.open is null.
Or you can provide your own ICoreWebView2 via the NewWindow property. In this case you are responsible for and get to choose how to host that ICoreWebView2 in some manner. The ICoreWebView2 you provide as the NewWindow will be the target of the new window navigation and connected back up via script to the return value of the window.open call.
Because obtaining a new WebView2 may require asynchronous method calls, you can use the GetDeferral method on the event args to stop the completion of the window requested event until you call Complete on the deferral asynchronously later.
You can see a working sample of the add_NewWindowRequested event in our sample app.

Add a Document_Open vba script to document when created from a template?

I have a template, Template.dotm, which is taken by a server and populated with data, then saved to a .doc. A user is then passed a link to this document so they can download it. I want to run a VBA script on that document when the user opens it.
Is there a way to accomplish this from within the template's vba script? The script of course runs fine if I simply double click the template to open an instance of it, but since the server saves a copy first, the script is gone by the time the user sees the document.
It turns out since the file was stored locally to the template but was being opened over the network, Word was confused and severed the connection to the template. I now have a copy of the template in a shared network drive, which I set to the attached template in Document_New.
Not the nicest solution, but it's working and was easy to implement. Thought I'd post for anyone who finds themselves in a similar situation.

How to code a self incrementing loop that carries on from the last value stored when the program is run again vb.net?

I am trying to create a self incrementing loop to act as a key field for my project, I have coded a counter, but every time I run the program again, it starts from 1 again, what do I do to ensure that it carries on from the last number written to file? I am a beginner to vb.net. Thank you :)
To achieve this, you can store whatever data you want to store as an application setting.
In visual studio, if you want to add a setting, go to the settings pane of the solution explorer.
Dont forget to call the save function when you are done with updating the value as the values wont get updated unless we call this function.
For more information you can refer to this URL
http://msdn.microsoft.com/en-us/library/bc6ws923.aspx
Alternatively, when the application is exited, you can save the required value to a file and when the program is opened again, you read the file and update the variable to the value stored in the file.

VB.NET ~ Sub Routines - can they be saved to a text file and then called?

I have about 100 sub routines that I need to use..I am going to be calling them into a web browser component do get some elements after each web page has completed.
Is it possible to create one sub routine and then has say a streamreader loop through a folder and read each text file in the folder to put the sub into a string?
I would then simply call that one sub into the webbrowser component but I didn't know if this was possible?
There would be about 100 different text files in the folder.
The thinking behind this would be that if I wanted to add more website instructions to the sub or take away from the sub I could just delete a text file.
How would one begin this crazy journey?
Thanks
That isn't really something you would want to do. Its also not possible since vb.net is a compiled language it can't just read the text of the code on the fly and implement it like that.
You are better off investigating another pattern that will meet your needs.
Actually you can programmatically create a vb.net program on the fly. I created a web program which rewrites itself as I see fit. Part of that code adds new subroutines to the same vb.net program. Basically writing more sub routines to itself and then it runs itself again. You can easily store your other subs into txt files and then recall the data later if you wanted. The trick here, however, is that you have to first add the sub routines into an entirely new file, then, when all the writing is done, you can then preform the following:
File.Delete(Server.MapPath("your old file name"))
File.Copy(Server.MapPath("your new file name"), Server.MapPath("your old file name"))
It should be noted that I make web applications, so it doesn't quite work the same. Using asp.net pages, the way I get the new program to run with the new sub routines is to run on the client side code, in which I include a little timed refresh, which fires once the rewriting task is finished. The page then refreshes with the new vb.net back end code in place.
In order to do this for a desktop application or whatever might require something else which I am not aware of.