How to get rid of ElementNotFound error in Capybara (JRuby) - jruby

I'm new to capybara and jruby. As one of my practice, i used way2sms site. After clicking Send SMS, the control was not able to find the element to enter the phone number.
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'selenium-webdriver'
include Capybara::DSL
Capybara.run_server = false
Selenium::WebDriver::Firefox.path = "C:/Program Files/Mozilla Firefox/firefox.exe"
Capybara.default_driver = :selenium
visit "http://www.way2sms.com"
page.find(:xpath, '/html/body/form/div/div/div[2]/div/div/div[2]/a').click
fill_in('username',:with=>"username")
fill_in('password',:with=>"password")
click_button('button')
page.find(:xpath, '//*[#id="quickclose1"]').click
page.find(:xpath, '//*[#id="quicksms"]').click
page.fill_in('MobNo',:with=>"mobile number")
page.fill_in('textArea',:with=>"Some message5")
page.find(:xpath, '//*[#id="Send"]').click
click_button('Send SMS')
when i run this, it shows the following error,
Capybara::ElementNotFound: cannot fill in, no text field, text area or password
field with id, name, or label 'MobNo' found.
Anyone help me to clear this problem...

Without any more information my guess is that one of these causes the field for mobile number to appear maybe through ajax?
page.find(:xpath, '//*[#id="quickclose1"]').click
page.find(:xpath, '//*[#id="quicksms"]').click
Do you run your scenario with #javascript? That would be what I would try first.
Since the default driver is rack_test and that can not handle any javascript. And to get capybara to use javascript driver which is selenium, by default, you need to tag your scenario in cucumber with #javascript. Or with :js => true if you're using RSpec. Read about it in the capybara readme here
The root of the problem is that there is no input with id 'MobNo'. Are you sure that it is the correct id for the input field?
You can also see what the webpage looks like too cucumber/capybara by adding the step "Then show me the page" before the step that fails.

Related

maple code output does not display on the screen

I've just downloaded the Maple 2020 trial version and I have zero experience on Maple programming. My problem is: when I do simple calculations such as 3+5 or 2*3, the result displays on the screen but, for other functions such as
factor(x^2+2x+1);
or assigning variables can't be done:
n:= 5;
m:=7;
m+n;
I do not see any results on the display screen after the enter.
Where am I doing wrong?
It seems like, I need to change some configurations of the Maple. After doing some search online, I found these suggestions in a web site. I have applied the following steps and my problem is solved: (Remember to apply globally not for the session.)
Open a new blank worksheet
On the toolbar, access Tools->Options.
Select the 'Display' tab
Ensure that the first entry is set to 'Maple Notation', and the second entry is set to '2-D Math Notation'
Click 'Apply to session' at the bottom left
On the toolbar, access Tools->Options again
Select the 'Interface' tab
Ensure that the entry 'Default format for new worksheet' is set to 'Worksheet'
Click 'Apply to session' at the bottom left
Now open a new worksheet in the same session. There should be a prompt '>'.
At the prompt, type 'version();' without the single quotes, but with the trailing semi-colon. This ought to return details of the precise Maple version you are running. If it returns something like
User Interface: 1133417
Kernel: 1133417
Library: 1133417
(precise numbers may be different), then you ought to be good to go - so try something simple like 1+1; at the next command prompt, (remember the semicolon).

Me syntax working instead of writing full control adress. Why?

I am kind of new to VBA programming in Access and I have banged upon strange thing. I have system of myListbox (multi-choice, two of them in testing regime, planning 5 total) to filter myReport contained in subform container by selected items in those listboxes.
Switching "On" filter works kind of fine (I will address it in different question after doing some research first), but switching filter off turned out to be problem. I was getting error message described here.
Managed to find a workaround. Since I have myReport bound to control in parent form, I am not switch off filter, instead I am changing it to resemble the bound field criteria, after that switch it off.
Code:
Forms![myForm]![myReport].Report.Filter = "((sourceQuery.fieldForBoundControl)=Forms![myForm]![boundControl])"
Me.FilterOn = False
but if I try this:
Forms![myForm]![myReport].Report.Filter = "((sourceQuery.fieldForBoundControl)=Forms![myForm]![boundControl])"
Forms![myForm]![myReport].Report.FilterOn = False
...or any other combination, or simply turning it off, I get error messages and procedure termination. Why?
Is my solution correct for future working of the app or I my setting myself for another Access trap?

Get specific nested table cell using Ruby Watir

I'm writing a Watir program to extract a specific number from a dynamically-generated table. The number is always in the second column of the fourth-to-last row in the table, but I'm getting the following error when trying to access the general table element:
Watir::Table: located: false; {:id=>"tContenido", :tag_name=>"table"}
Code
require 'rubygems'
require 'watir'
browser = Watir::Browser.new :firefox
$log = Logger.new('logs\test.log')
$log.info("TEST")
$log.info browser.table(:id, 'tContenido')
HTML Structure of the target page (1)
HTML Structure of the target page (2)
Any help would be greatly appreciated, thanks in advance!
I think this is the one you are looking for:
browser.table(id: 'tContenido').tr(class: 'tr_gris', index -1).td(index: 1).text
Alternately, if you are having problems with a table, you can just put everything into an array of Hashes:
browser.table(id: 'tContenido').hashes
You can write the following WATIR code
puts b.table(id: 'tContenido').trs[-4].tds[2].text

MS Access 2007 - controlling UI behaviour after attempt to insert duplicate record

Creating a simple UI using MS Access, hoping to do minimal actual coding (actually helping a friend who is not a coder).
Simplified requirement: Single table, primary key is phone number, lots of other non-mandatory fields. Display a form allowing just the phone number to be entered, if a record with that key exists display the full record, if a record with that key does not exist bring up an form allowing the other fields to be entered for this phone number and hence create a new record.
Q1: Any simple way to achieve this kind of function? Example?
We've got some of this going with a standard form, can execute code if insertion fails, but a standard dialogue box is displayed warning about the duplciate key violation.
Q2: How can we trap that attempted insertion, avoid having the dialogue come up?
You will have to get your hands dirty and write some code to get this outcome. A starting point would be something like this presto code. Post back if you get stuck on any of the parts.
If fCheckIfRecordExists(lYourKey)=True then
Docmd.OpenForm “frmEditExistingRecord”
Else
Docmd.OpenForm “frmEnterNewRecord”
End if
Public function fCheckIfRecordExists (lYourKey as Long) as Boolean
‘Code to check if a record exists, simple method is to use dLookup or a count SQL statement with the criteria as the key you are trying to find
End function
EDIT:
First things first make a form with 1 text box called txtPhone_number and a command button called cmdSearch.
Next put this bit of code in the module behind the form
Public Function fDoes_record_exist(strPhone_number As String) As Boolean
If DCount("Phone_number", "tblYour_table", "Phone_number=" & strPhone_number) > 0 Then
fDoes_record_exist = True
Else
fDoes_record_exist = False
End If
End Function
Next you need to put some code behind the click event of the command button. This code can be expanded on to check for a valid phone number later if you want
If fDoes_record_exist(Me.txtPhone_number) = True Then
DoCmd.OpenForm "frmShow_existing_record"
Else
DoCmd.OpenForm "frmEnter_new_record"
End If
That should set you on your way nicely but post back if you run into problems
Here is an overview of the process with Access logic:
You need an unboud control labelled Phone in the form header, where user will be able to enter the phone number to search. You need to use the After_Update event of that control to trigger your search. There will be a second Phone control, bound this time, in the Detail section of the form for effective data entry/update.
Use the Form_Error event to intercept the error message when user tries to save a duplicate key, in order to display a nice message, and eventually Cancel his changes.
The advice from Kevin Ross to use VB Code is clearly one approach, and I think is appropropriate if we anticipate less trivial requirements in future. However I'm in a situation where I'm helping someone with zero coding background and hence if possible I'd prefer to let them use simple Macros rather than full-scale VB.
As it happens the functionality I require can be implemented with just Macros, and it depends on the suggestion from iDevelop.
The outline of the solution I used:
Create an InitialEntry form with no association to any particular table, it has:
a data entry field for the telephone number
a read-only text box where I can display a message
a button labelled Add
a button labelled Show
I write three macros:
A macro AlreadyExists that displays a message saying "We already that one"
A macro NewEntry that opens a data entry form for my table, in Add mode, and which copies the phone number from InitialEntry!TelephoneNumber
A macro TestForExisting this uses a condition
DCount("*","MyTable","[PhoneNumber] = [FormPhoneNumber] " ) > 0
to control whether to execute AlreadyExists, and a similar test to control whether to call NewEntry.
While this is not as efficient as VB, it does seem to be understandable by a non-coder, so at least we can implement our application.

Designing Database

I need to design database with frontend as HTML.
This is my first attempt to do this.
What I need is,
- User can input a word from HTML page, click submit
I will query the word to get a URL from database and user sees that webpage(pointed by URL).
Just enter word, submit and get the webpage displayed.
People suggested using JSP/Access. I am new to everything.
Can you please point out what exactly I need to do?
Thanks a ton.
Following is the way you need to approach
Step1:
Create an HTML page which can take an input from the users
Step 2:
After getting the data from the user, create a connection to the database and pass the searched string as an input paramater.
Step 3:
You will get a result set from a database
Step 4:
Iterate through the result set and display in the html page, if you require the url to be given for those url, so when user clicks So that he will be directed to those websites.
Sample Query:
Select * from table1 where url_Word like '%Search_String'
This will be the procedure that you need to follow to complete your work.
You do not need a database you need a text file. If this is a school project you need more information.