Google search input text box can be found using name but not id - selenium

I am trying to go to the url "https://www.google.co.in" enter the word "Googling" in the input text box and then click on the search button.
The input text box has id "gs_htif0".
So the statement
driver.findElement(By.id("gs_htif0")).sendKeys("Googling");
should work. But it's not. The statement
driver.findElement(By.name("q")).sendKey("Googling");
is working fine. It fills the search box with the word "Googling".

It seems you tried incorrect id. Please check with :
driver.findElement(By.id("lst-ib")).sendKeys("Googling");

Related

Insert/replace string in existing text form field in Word (VBA)

So I'm trying to create a conditional dropdown in Word. I've used a Legacy Drop-Down Form Field with multiple options.
What I want to happen is when one of the options is selected from the dropdown (and then I guess you have to Tab to enter it...), the Legacy Text Form Field below, that has a simple default text, should populate with a new string from the case statement.
Things that I've already done/got working:
the drop down is working, and on exit it runs a macro
case statement is written out
the result of the case statement is in a variable (string type), let's call it StringVar
can pull the text form field's text (default text) with ActiveDocument.FormFields("TextBox").Result
What I figure out, however, is how to replace the default text in the already existing Text Form Field with the case statement's string variable text.
I've tried
ActiveDocument.FormFields("TextBox").Result = StringVar
but it doesn't change anything inside the text form field. The default text is still there.
So I can answer my own question after pondering and being hit with an "oh, duh" moment.
I had unprotected the document (ActiveDocument.Unprotect Password:="") in order to do this:
ActiveDocument.Content.InsertAfter Text:=("This is my text")
because I was wondering if I was grabbing the right string.
Turns out,
ActiveDocument.FormFields("TextBox").Result = StringVar
DOES work. BUT the file has to be protected (filling in forms) for it to replace the string in the text form field. Otherwise, nothing shows up even though the result had indeed been updated. Fancy that.

Visual Basic read, split, modify .txt file

I'm using visual basic 2010 and im a new user. I have my project called mini database.
I want to export and display my text file in my program.
05655606515|Working|John
12345456445|Working|Alex
42348564041|Not Working|Jean
I have my 3 columns table and i want an unlimited rows. The rows and depends on how many lines are there in the text file.
The first column a text box, which i can modify what i like to enter on it.
The second column is a combo box which i can select if it is working or not.
And the third column is also a textbox which i can type the name of a user.
Please help me to have my project. Thank you stackoverflow!
Make a form with a textbox, combo box, and a second textbox.
Add a command button to save the data, one to show data, and possibly one to cancel and one to exit.
Fill the combobox with the appropriate items.
In the click handler for the save button, write the data to a file with "append".
The show data button can read the file display the text in a multiline text box or rich text box.

Selenium, using xpath to click a button with a similar content

I want to click a button that contains "Add" as text.
ie:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])").click()
however it's not practical to do this:
driver.find_element_by_xpath("(//a[contains(text(),'Add')])[1]").click()
It would be fine, except the page has a button with text "Add User", and it clicks that instead. Is there a way to only click it if it is EXACTLY "Add" and not just contains "Add"?
You can also try :
driver.find_element_by_link_text("Add").click()
link text will match links who's text equals Add and it doesn't match text which contains Add as part of it.
This should work for you:
driver.find_element_by_xpath("//a[text()='Add']").click()
You should change your xpath to require an exact match instead of a partial match.
driver.find_element_by_xpath("//a[text()='Add']").click()
Using text()= requires the text on the button to be equal to 'Add' and will not find other buttons that happen to contain the text 'Add'

Word: remove page from multipage userform

I want, depending of the previous choice from the user just let some tab's being seen.
Once i am new in VBA, i start showing all the tab's and after the choice from the user, i remove the tab's that i don't want. For that i am using this line of code
MultiPage1.Pages.Remove "name of the tab"
The problem is, if i don't have the same CAPTION and the NAME field of the tab the tab is not remove.
If anyone have a diferent solution for this or another away to remove without have to change the caption for the same name of NAME field i would be thankful.
Thanks
You can give a page of a multi-page control a different name from the caption in the Properties Window. You can access it from the View menu.
I've highlighed the name of the control in yellow and the caption in aqua.
If the captions are unique, you could use a Select Case statement to get the name, based on the caption. Are users actually typing in the caption of the tabs they want, or selecting from check boxes? In either case, the captions would have to be unique, so you could do something like:
Select Case True
Case Check1.Value
MultiPage1.Pages.Remove Pages("kp").Index
Case Check2.Value
MultiPage1.Pages.Remove Pages("jp").Index
End Select
That's a bit rough, but is that the general idea?

SAS EG dynamic text field

is there a text field control in SAS EG ?
how can i set the selected prompt value ( parameter) into a text field(header is ok too) that will show in the report?
sorry , im new in SAS , so those term im using might not be the correct one.
It is possible to add prompted value to a header.
First go to the Prompt Manager under View menu
Click Add to create a new prompt
Give your prompt a name eg. HeaderText and a display text like Text to display in report header. In the second tab, make sure it's of the type text.
Open the properties (NOT modify, but bottom option of the right click) of the report you want your text to be displayed in.
Go to the prompts screen and add the prompt you just created and click OK.
Now open the modify window of the report.
Go to the titles screen, disable Default Text and enter &HeaderText. in the text field.
Run your flow. It will prompt for a text and that text will be printed in the header.