I am just trying to understand and learn selenium. I used IDE to record my actions and tried to playback but I am kind of stuck on the first step.
What I am trying is basically login to our internal site and then click on menu bar to navigate to an internal page. Selenium logs in but fails at the click event with error message -
[error] Element css=#ui-active-menuitem > span.wijmo-wijmenu-text > span.wijmo-wijmenu-text not found
This site is generated using primeface and when I see the source code, the line that generate error is something like-
<div align="left" class="container"><div id="menu"><ul id="menu_menu"><li><a href="javascript:void(0)">
<span class="wijmo-wijmenu-text">Home</span></a><ul><li>home</li></ul>
</li><li><span class="wijmo-wijmenu-text">Tills</span><ul>
<li>Manage........
I must tell here that as long as I am not clicking on above menu item, I am able to run all tests through Selenium ID but clicking on above menu after login is essential to get to inner pages.
You help/guidance is much appreciated.
Thanks
I'm begining too and having same problem. This commands work for me:
clik
link=menuName
clickAndWait
link=subMenuName
Hope it helps.
Maybe element not found just because it not loaded yet.After log in you can try to use command
waitForElementPresent and then click on element.
It seems you refer to an element by css, you can try id or name
I think before appearing the menu Selenium trying to click.
Just use
Thread.sleep(5000); // for five second waiting or more you can use
Another way use -
WebDriverWait wait = new WebDriverWait (driver, 30); // maximum wait 30 seconds
wait.until(ExpectedConitions.PresenceofElement(By.id("Menu_id"))).click();
Add wait and never try learning selenium through IDE .
disadvantages of using IDE is you cannot add conditions ,loops and wait in your code and cannot maintain the framework.
Related
I am a fresh Protractor user trying to write some Protractor E2E test.
The page I am testing has some TextInput boxes, and a app-map(google map).
When I tried to enter some charactors by using "sendkeys" function, the script failed with the error "script time out".
I assumed that it took too long for protractor to load the entire page.
For this page I just want to find the textbox elements and enter some charactors. Could anyone help me to igore the loading of the google map?
best regards
shixiang
Set browser.waitForAngularEnabled(false) in your script file this ignores the wait time to load the components.
Use expected conditions to make your script wait till the text boxes appear. here is the link for more info on expected conditions
https://www.protractortest.org/#/api?view=ProtractorExpectedConditions
Add allScriptsTimeout in your config file which will override jasmine default timeout("allScriptsTimeout: 2400000"). You can set the timeout value depending on your requirement. it's in millisec.
Hope this helps
I am trying to click hyperlink called "order create" in my application.I have used following code.When I execute this step in eclipse debug mode or selenium IDE, I am able to click particular link.However when I try to execute via Java mode in eclipse, my code is not able to click this link.Do we have any other option to click this link?(i.e wait and click something)
Driver.findElement(By.xpath(//*[#href='link' and text()='Create Order'])).click();
You can use explicit wait with expected condition elementToBeClickable to wait for the element to be clickable
WebDriverWait wait = new WebDriverWait(Driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#href='link' and text()='Create Order']"))).click();
Hi if your drivers clicks before page load then there is a synchronization issue
simplest way to avoid synchronization issue is use of universal wait i.e implicit wait which says driver instance to wait for a maximum of defined (time seconds) before sending any error.
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
in above code you are telling driver instance to wait a maximum of 20 seconds for the individual webelements in the current session.Note above wait is applicable for all webelements.
I have used Thread.sleep(2000); before my test step.It has solved my issue.
I am working on a Hospital front desk ADF project, here I need to generate visit slips these dont require print preview.I want to get to print the slips without any print dialogs nor do I want a popup window. I tried lot of stuff found on the net but nothing solid has come up..
Tried this.print on the Jasper report, tried the same through Java but I am getting dialog.
I am working on an intranet so the security aspect is out of the discussion so how so I make this work?
This is a suggestion rather than an answer, but I can't write comments before I get 50 points of reputation (thank you for the warm welcome, StackOverflow!) - maybe one of these will help:
1) Printing an html file using java without showing print dialog to the user
2) How would I suppress the print dialog in this example?
I was able to perform the silent print, I used a popup window to call a servlet which generated the required visit slip and displayd the same on the pop window. For the silent print I used
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:this.getPrintParams().constants.interactionLevel.silent});this.close();");
I had to make a couple of changes to IE, I added my url to the trusted site option in IE. I enabled js in acrobat and also pointed acrobat to the trusted sites in IE. This resolved silent print but am stuck with another issue..
I am not being able to close the window once print is done.. I tried this..
"var win = window.open('PrintPopUp.jsf','_blank',\"height=300,width=200,scrollbars=no," +
"status=no, resizable=no, screenx=0, screeny=0\");win.onclick=function(){setTimeout(function(){win.close();\n},9000);}
But its not working in IE 11.. any suggestions?
Well I found out a way to do this..
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,
"var pp = this.getPrintParams();pp.interactive=pp.constants.interactionLevel.silent;pp.NumCopies=1; this.disclosed= true ;this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:pp});");
This adds pdf javascript to the generated pdf..
Once the pdf is displayed on the popup page it performs the silent print.. Hope this helps someone in the future..
I want a solution for the following scenario:
In a page I am uploading an xml and while clicking on the upload button I am going to recieve an pop up for confirmation (I am able to detect this), after this again I am recieving an pop up which I am not able to detect (The page is still getting loaded in the browser ). Kindly help me to sort this out .
I have tried with many solutions for this like: get window ids,titles .
Thanks
You can you use -
$sel->get_confirmation()
This retrieves the message of a JavaScript confirmation dialog generated duringthe previous action. By default, the confirm function will return true, having the same effectas manually clicking OK. This can be changed by prior execution of thechooseCancelOnNextConfirmation command. If an confirmation is generatedbut you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visibledialog.
NOTE: Selenium does NOT support JavaScript confirmations that aregenerated in a page's onload() event handler. In this case a visibledialog WILL be generated and Selenium will hang until you manually clickOK.
Returns the message of the most recent JavaScript confirmation dialog.
You should always refer to WWW::Selenium - Perl Client while working with perl and RC.
I have found what is the problem #amey ...I am tring to upload an file which is not actually not permitted due to some security issues with firefox... There was actually an work around for this
http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/
.....Which will not work with latest Selenium RC with Firefox since firefox have removed the support for enablePrivilege
https://support.mozilla.org/en-US/questions/944433.
So it is a mandate to shift to WEBDRIVER it seems.............
http://git.erp5.org/gitweb/erp5.git/commitdiff/06898bbfae4f238b7e79ce05048646529216064e
Thanks for your support....
my solution was using the function:
$driver->execute_script("Events.invokeEvent('UserDetailPage:UserDetailScreen:UserDetailToolbarButtonSet:UserDetailToolbarButtons_DeleteUserButton_act', true);");
analyzing what the javascript code does when the Accept button was pressed. and executing that code in the function.
I have added a new preference page in my application. and performing some task when user press ok button. problem is my code is executing even other node(preference page) is selected in the preference dialog.now i need to check whether currently selected node is my preference page before executing my code inside ok button. any help will be appreciated.
Sorry to say, but I think your problem have started a bit earlier. If done without too many hooks and nooks, you should only be called when necessary, so it sounds a bit odd to me.
I can usually just override performOk or in some cases performApply without these problems.
Have a look at the docs, just in case