Unable to put number in text box in selenium - selenium

I want to put the number in the textbox and click on Get App link When I am using XPath
command:
driver.findElement(By.xpath("//*[#id="ngdialog1"]/div[2]/div/div[1]/div[1]/div[1]/input")).sendKeys("123456789");
When I run the script the popup window is opening but it does not enter the value in text box.
Please refer screenshot.

Add a wait, if necessary, as Andersson suggested, then use this xpath:
driver.findElement(By.xpath("//*[contains(local-name(), 'input') and contains(#name, 'number')]")).sendKeys("123456789");

Related

Robotframework checkbox is not clickable

i really try difference staff to try that this script works but no way, i used name, id, selector, xpath didnt work, i use click element, checkbox should be selected, select checkbox, click button, really i do not understand what i am doing wrong.
this is the website code for the check box enter image description here
this is my robotframework script:
click element css=#nutzungsbedingungen
and this is the error that appears on my terminal:
ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (354, 445). Other ele
ment would receive the click: ...
Thanks for your help
That is because the driver is not focusing in the page - for some reason it gets off the page. When it happens to me, I usually click to focus on the nearest element that I want to check.
The other reason could be that there is an iframe, so first you should be get into the iframe and then could check the box.

How to click on the text after scroll down in Selenium IDE

The web page that I am using has a list of links
My use case is to perform page down operation and select the link at that location.
I performed page down using the following command
storeEval with the Target as selenium.browserbot.getCurrentWindow().scrollTo(0,20000)
The above action performs the page down
My next action is to click the link that is shown
I used the command clickAtAndWait with the target link=target_link
The above action clicks the text target_link at the top of the page (which is not visible) and not the text that is visible.
I need to perform page down and click the text target_link that is visible.
What change needs to be performed for this action?
In the Selenium IDE you can use the Command focus with a Target value of an element at the bottom of your page.
For example:
Command: focus
Target: id=nextButton1
Value:
This will scroll the Selenium IDE (Firefox) window down so the "Next Button" is just visible at the bottom of the screen. The Value parameter is not used and has been left blank.
You need to find the element and then use the click command.
Sample code:
elem1 = driver.find_element_by_class_name("wtb-search-submit")
elem1.click()
Read at http://selenium-python.readthedocs.org/en/latest/locating-elements.html on how you can locate the element. Hope it helps.

WebDriver - sendKeys(input) does not complete before sendKeys(Keys.RETURN)

My test is entering keys in an search text box, that's mostly ajax, and then pressing enter from the keyboard. There is no button to "start" the search so we're using the Enter key.
I'm using ChromeDriver as Firefox is not supported for our application with regards to this flow.
For my webdriver code (java), I'm having it do this:
searchIcon.click(); //opens the ajax overlay of the search text box
searchBox.clear(); //clears whatever text is already there
searchBox.sendKeys(input); //enters in the input text
searchBox.sendKeys(Keys.RETURN); //press return to start the search
The problem is, I noticed that the input text is not fully typed into the text box yet and the RETURN has already taken place. Basically, I'm doing a search of part of the input text that was entered.
Anyone encountering this? I tried to add an implicitwait before the Return action but since the elements are already loaded, that isn't going to help.
Try this, once you enter the input into the search box, check whether the text is completely present or not inside the text box again using if statement, if complete text is present, then do the sendkeys(keys.return) part.
Just give it a try. Because once you entered the text into text box, in the next step the element obviously will be there.
Thank you,
Shravan Kumar.T
I also encountered same issue while executing my test. And it get resolved by updating webdriver to the latest version.
webdriver-manager update --versions.chrome=2.33
webdriver-manager start --versions.chrome=2.33

Selenium Webdriver 2.30 unable to identify object on the standard Salesforce lookup pop-up window

I am using Selenium Webdriver to automate functional TC in Salesforce application.
Test Scenario:
- On a case page, clicking the "Lookup" i.e., search icon opens up standard Salesforce search popup. I need to input specific string to the search field and click "Go" button.
Although I am able to click on the Search button, the script fails to identify any field on the popup.
I used Alert(), getWindowHandle & iterator functions to verify if the driver is working on the popup window. Yes it is.. the popup is is the working window. I could able to confirm this using the Java id for the browser window. But still it fails to identify any fields.
Let me know if any of you faces similar issue and any solution.
Do let me know if you like to have access to my working sandbox. Would be able to manage it.
Thanks, Manju
I believe the problem is that the elements inside the popup window are in a frame. After switching to the new popup window you need to switch to the frame first before being able to access any of those elements using:
WebElement frameLocator = driver.findElement(By.id("searchFrame"));
driver.switchTo.frame(frameLocator);
Further to Bob's answer you'll also then need to switch to the "resultsFrame" in order to use any of the links returned by the search. Note that in order to switch to a sibling frame you must first go up to the parent of the frameset using:
driver.switchTo().defaultContent();
(frameset guidance here: http://darrellgrainger.blogspot.co.uk/2012/04/frames-and-webdriver.html)
With Selenium IDE:
I was able to select the Salesforce PopUP with this code:
Command:selectPopUp
Target:
Value: Your popUp title
And the result frame:
Command:selectFrame
Target: name=resultFrame
Value:

How can I find text location with Selenium?

I'm trying to find the location of some text on a web page using Selenium.
I can use the isTextPresent function to tell me if the text occurs, but then I want to know where it actually is.
The wider problem is that I want to click on this text.
The problem is that I don't seem to be able to click on this text, which I think is in some control embedded on the page. So, it doesn't seem to be detected as a link or button or option etc. However, I need to click on it to make a selection.
Any thoughts?
Your solution xpath=//*[text()='hello'] will click the first clickable element with the text "hello" in the source code. If you want to be more specific, you can add more cases to the xpath like this
xpath=//*[#id='exampleId']//*[text()='hello']
Now this will click element with text 'hello' that's found after some element with id 'exampleId'.
Xpath is great usage and you should answers above. However, I realised, that sometimes Selenium does not allow you to click something, because it thinks the text is hidden by CSS
So far I do not have any workaround for it and instead of clicking a button I am closing completly whole browser window.
But in my case its div hidden by CSS showing actual version number of such application. So I only take a screenshot of it:
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
File destination = new File("path/to/outputfiles/versionNumber.png");
FileUtils.copyFile(scrFile, destination);
Got it !
I don't know the answer to how to find the location,
but, the more important bit is to click on that text.
I can just use an XPath locator in the click method, like :-
Click(xpath=//*[text()="hello"])
This will click on the element that has a text value of "hello".
In my case, this is unique, so that's specific enough.
${x_axis}= Get Horizontal Position xpath=//*[text()="Log files"]
Get Horizontal Position returns the position of 'Log files' wrt the left end(X-axis length).
the position is an integer value... so can be compared easily as well.