How to clear values from textbox using Selenium in VBA - selenium-chromedriver

When I tried to clear values from textbox or combobox using .Clear an error shows like
Selenium error, element not interactable. Session info: chrome= 76.0.3809.87 Driver info: chromedriver =76.0.3809.25
```Dim bot As New WebDriver
```bot.FindElementByXPath("//*[#id='textbox/combobox_ID']").Clear
I expected the output is to clear already existing values from textbox/combobox.

Using, Xpath which you already used in your VBA code, you would be able to clear the search box, if it's not getting cleared then after loading the website code, kindly use a wait time and then code for clear.
For ex:
Dim bot As New WebDriver
with bot
.wait 3000
.FindElementByXPath("//*[#id='textbox/combobox_ID']").Clear
new input codes
End With
Above logic might work.

Related

How to close browser popup in robot framework?

After login in Chrome browser, I am getting a save password popup from the browser. I want to handle that popup and want to close that using Robot Framework
Browse popup window
Thanks
This question has been asked and answered before with a pure Python context. This answer continues on this SO post for a working Robot Example.
The popup you see is generated by Chrome itself. It's not an HTML alert. For this reason none of the Selenium2Library keywords will have any effect on it. Nor wil settings cookies or javascript.
These settings can be manually set using the chrome://settings link. Go to advanced settings and then scroll down to Passwords and Forms. Untick the second item and this will prevent the popup.
To do the same automatically in Robot Framework the WebDriver needs to be started with additional preferences:
Chrome With Preferences
${chrome_options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${prefs} Create Dictionary credentials_enable_service=${false}
Call Method ${chrome_options} add_experimental_option prefs ${prefs}
Call Method ${chrome_options} add_argument --disable-infobars
Create WebDriver Chrome chrome_options=${chrome_options}
Go To https://secure.url.com
This key things here are credentials_enable_service=${false} where it is important to use ${false} and not false, as the latter is interpreted as a string and then added to Chrome as "false" instead of the correct value false.
The second item is that preferences are not added as arguments but through assigning a dictionary to the prefs property of the ChromeOptions() object like so: add_experimental_option prefs ${prefs}
I do not think this is real to be honest (as it's property of the browser.) Are you having issues with that? The only thing you can dismiss is javascript alert and probably the best way to handle this is:
${alert} = Get Alert Message dismiss=${dismiss}
I have this in my test teardown with Run Keyword and Ignore Error, it makes me able to fetch optional js alert content and debug (also dismisses it do the rest of the suite can be executed.)
Three Ways To do do it.
1) Many a times, Once pop-up appear on screen and Disappear a cookie is set which you can view in developer console-> application. If you set this cookie with value using Add Cookie keyword. Pop- up wont appear.
2) if first doesn't work, then open developer tools and monitor the local store from developer tools -> application and close the pop-up. U will notice some variable with a value is stored in local storage. You can set that value using your script and u wont see the pop-up while executing variable.
3) If first and second doesn't work, the pop-up is most likely linked to a javascript variable. set java script variable using Execute Javascript Keyword and your problem must be solved.
Talk with your dev team, to see which way will work for you.

If there is a way to restore user input after failed server side validation using angularjs?

I have a page using angularjs, everything looks good except one thing: after user clicked submit button and the server side validation failed, the user input will be gone, but when I checked the html tags, the value="xxx" attribute saved the lost value, how can I get and render it to my page?
Thanks a lot!
Not sure about your exact scenario, but what you can do is to make the copy of original model object and bind it to form
$scope.editItem = angular.copy(originalItem);
Bind editItem to the form.
If the server validation fails just call the above statement again and the editItem would be restored to original value.

Inserting JSON file in Meteor

I have a form and I need to put the data of that form in collection, using coffeescript
I am currently doing these in my client coffeescript file:
#Question = new Meteor.Collection('questions')
Template.question.events
'submit #question-form' : (event) ->
QuestionData = $('#question-form').serializeJSON()
Question. insert QuestionData
I am not sure whether these data is being inserted or not. Please give me some useful ideas
Thank You in advance !!!
Tools you can use:
1) You can add a line to javascript:
debugger
your client browser will stop when it reaches that line. Sometimes you have to be in an inspect element screen already before it triggers. I do this often in Chrome and Firefox. Firefox has a debugger tab; chrome, a sources tab.
2) You can use mini-mongo in the client to check for the new record. In the console (you can get to the console as a tab as described above) type
Question.find().fetch()
You can also write
id = Question.insert QuestionData
console.log 'Question.findOne("' + id + '")
which should give an easy to copy and paste.
In a separate terminal/dos prompt fire up the mongo console using.
meteor mongo
then to list all the questions in the mongo console type
db.questions.find().pretty()

After acDialog form made not visible ms Access eventually throws error when exiting

I've got a search results form in my Access client which uses the trick of being a form opened in acDialog mode. If the user cancels the search the form closes itself, if the user selects one of the search items, the form writes the result into an unbound field and then makes itself not visible.
The calling code will suspend (because of the acDialog mode) until either of the two events described in the previous paragraph happen. The calling code checks to see if the form is still loaded - when it knows a search item has been requested, so it retrieves the item from the form and then closes it. If the form was already not loaded, we assume the cancel route was chosen.
the search results datasource is a select statement "SELECT * FROM details ORDER BY ..."
This trick has worked for a while in the code where "details" is a linked table to another Access database
I am porting to SQL Server, and the details table is now dynamically linked at startup to the correct SQL Server instance. Using the following connection string
ODBC;driver=SQL Server;SERVER=ROO\SQLEXPRESS;DATABASE=Test_DB;UID=my_app;PWD=xxxx;
(Passwords etc changed to protect the innocent)
When Access exits the application (AND ONLY THEN) - if the path through the code has resulted in using the visible = false trick then it exits with an error message. There is no error message if there is an application exit where the path has been through the search form but the form closed itself before returning.
The error message is:
Cannot access database because of Error [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified
and will now Exit.
I need to find out precisely why this is happening and stop it.
I solved the problem with a work around. I created a global variable for the form result and then always closed the search result form itself. The underlying routine that was trying to pick up the result just uses the global variable.
This proved that making a Dialog box invisible to retrieve results is not reliable - the problem disappeared as soon as I changed it.

Windows 7 SP1 breaks access (not the ADO way)

So our corporate IT dept has determined that it is time to force SP1 on everyone's PC's.
Which means I need to get my Access 2003 ADE application working with the stupid ADO incompatibility problem.
I got the ADO portion to work by following KB2517589, but now several of my textboxes say #Name?.
These are bound to code, so, for example, the data field in the textbox is =CalcShippingAddr().
As a test, I replaced the code with the following:
Public Function CalcShippingAddr() As String
msgbox "Func Called"
CalcShippingAddr = "Test"
End Function
This works fine on my dev machine, but as soon as I make an ADE and send it to a PC without SP1, I get #Name? on the textbox. The msgbox nevers pops up.
Any ideas what might be happening?
This is a fault to do with the field calculation, I haven't seen it myself but have heard that clicking in to the relevant text box would then show the value although this is not a solution. I would always recommend using unbound forms as you can control step by step what your fields/objects are doing. As you already have a custom function to calculate the shipping address then it should be simple enough for you to add the code the the forms 'Open' or 'Load' event e.g.
Private Sub Form_Load()
textbox = CalcShippingAddr
End Sub