Unable to locate button element - selenium

I can see the enabled button while running. I can select that button using Selenium IDE and the xpath. But when it comes to running using WebDriver it is not able to find the element.

Are you using the localhost? because sometimes if it takes some extra seconds for the Web Browser to load (for example Firefox), then when Selenium tries to do the action it doesn't find the elements obviously resulting your error.
Use the pause command, for example 5 seconds, so that the Selenium waits 5 seconds before the action is executed, giving time for the website to load.
Try the coding somewhere on this level
driver.manage().timeOuts().implicitlyWait(5,TimeUnit.SECONDS);

Related

Robot Framework Selenium Library - Don't wait for result from submitting form

I'm new to using Robot Framework/Selenium Library.
I'm trying to create a test that enters values into form fields and submits the form by clicking a button.
I only want to check if an alert is present immediately after submitting the form, then close the browser and end the test but at the moment the test is waiting the 2-3 minutes it takes for my script to finish running and the new page to be loaded.
Is there a way I can tell Selenium not to wait for the result and check for the alert immediately then close the browser after verifying if the alert is present or not? The flow of the test currently is:
Test Alert Present
Open Browser And Maximize
Select From List By Value id=mySelect myValue
Click Button id=runScript << waits 2-3 minutes here
Alert Should Be Present
Close Browser
Thanks
Edit:
This seems to be a problem specifically when running tests with Google Chrome.
When running with Firefox, Selenium seems to wait 5 seconds before continuing with the next test instructions.
First, get the values to understand if selenium is waiting or anything else:
Get Selenium Speed
Get Selenium Implicit Wait
Log them to console then we can decide next steps.

Selenium IDE Test Runs in GUI - But Fails when run in CL (linkText not Visible)

When my saved project and test runs in the Selenium IDE GUI it's fine, but when I perform the same test called via the command line side runner it fails. The issue appears to be the linkText not being visible, but I don't understand why it would fail when it runs fine form the GUI.
You can see the last step (8) as passed, with reference to the linkText
I then save the project in my local folder
And run it again using the side runner command
ElementClickInterceptedError: element click intercepted: Element Corporate Project/Program/Event (CORP) is not clickable at point (798, 199). Other element would receive the click: ...
It appears that the linkText maybe covered? The weird thing it's visible to me when the selenium test is running, just before it hangs. I did try to add some wait commands, i.e. "wait for element visible". But didn't seem to help.
Maybe I didn't insert the command properly?
I feel like I must be missing something obvious. Any suggestions?
I've found similar threads on GitHub that indicate differences in the way the IDE core and web driver work. One user indicates it actually IDE that's clicking through an overlay. I've managed to overcome my issues using simple pause commands, unsure why the wait commands didn't work for me.

Seleniumlibrary command not working with Ride?

The issue I'm having is with the command Go Back from the selenium library within RIDE.
I have tried to input the Go Back command into a test script im running. The website should then simulate a click on the back button within the browser (chrome). It however does not seem to work while it does tick off the step as done and passed. I googled some stuff and found out sometimes the browser isnt ready loading when trying to perform the next command and thus it could create an issue. Because of this i tried to implement the Set Selenium Implicit Wait 10 seconds command
In the img link below (can't post the img because im not 10 reputation) you can see that I have the command Go Back and Set Selenium Implicit Wait 10 seconds. Neither however seem to work (notice that while the timer is suppose to wiat 10 seconds. it is marked as completed in 00:00:00.003
https://gyazo.com/fa18566997436989ab5a6503b9064965
I noticed that both come from the seleniumlibrary and while installed and imported (or Close Browser would not work) neither works. I'm not sure what im doing wrong here. In the picture below is how i wrote it down in the testcase.
https://gyazo.com/7d914c7c74999177ae2dca4a02d4a4bb
Any help would be much appreciated into making the bowser use the back button and/or explaining why certain aspects of the seleniumlibrary don't seem to work.
See the implicit wait section. It can be read like "the maximum time when waiting to find the element". When you use the Go Back keyword, there is no element to wait for, so it is immediate.
See here a complete example (that would work as long this question is on the first results page):
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Move Back On Browser
Open Browser https://stackoverflow.com/questions/tagged/robotframework%2bselenium?tab=Active Chrome
Scroll Element Into View xpath=//a[.='Seleniumlibrary command not working with Ride?']/../..//div[contains(#class, 'excerpt')] # Scroll to excerpt, because Cookie Policy ovelay is over URL element
Capture Page Screenshot active_questions.png
Click Link xpath=//a[.='Seleniumlibrary command not working with Ride?']
Capture Page Screenshot target_question.png
Set Selenium Implicit Wait 10 seconds
Go Back
Capture Page Screenshot after_go_back.png
[Teardown] Close Browser

Selenium IDE - Slow is too fast

I want to create tests with Selenium IDE for SharePoint 2010. I set the control in Selenium IDE to slow, but it is often to fast and the test fails because javascripts are loading etc.
Is there a way to slow down the script?
I had best results using functions like waitForElementPresent or waitForVisible. This way you can just wait for specific element you want to work with. For example if you click link Next and want to click Previous when page reloads, instead of writing andWait abbreviation you could use something like this:
waitForElementPresent(Previous)
click(Previous)
Aside from placing pause(waitTime) between your statements, I would recommend to transition the IDE scripts to Selenium RC and use the selenium.setSpeed("milliseconds"); statement (java) to control the execution speed.
Using pauses means your tests are going to pass while your server is under the same load but they will start failing as soon as your server is under heavier load.
You should use the clickAndWait command, which waits for the next page to load before continuing with anymore commands.
click/clickAndWait - performs a click operation, and optionally waits for a new page to load.
waitForPageToLoad - pauses execution until an expected new page loads. Called automatically when clickAndWait is used.
Reference
Put this after your click commands: pause(length of time in ms)
For example:
pause(1000)
This pauses for 1 second. Start with a higher value until it works, then work your way down to find the smallest possible pause.
You can set the speed of each step with Selenium IDE
Command Target
setSpeed 65 (set the speed of item)
setSpeed 0 (reset the speed)

Selenium: How to stop RemoteRunner.html from getting invoked

I am using selenium for one for my Java applications on linux. The application invokes a mozilla browser, fills login details (username and password), and then submits the form. I am able to achieve this using selenium, but every time a url is selected 2 instances of mozilla is getting invoked. One instance is that of the url selected and the other instance is a RemoteRunner.html which has selenium command history and other details.
I don't want this page to be invoked. Is there a way to stop this page from getting invoked?
Thanks and Regards,
Sunil.
The RemoteRunner window is required as it is controlling the application under test within the other window. You can run Selenium in a single window using the command line option multiWindow=false however this uses frames, which can sometimes cause issues with the application under test.