I want to reset modem with selenium. But I am facing a problem. I am trying to click but no click operation has been done. modem click is zyxel.
<li style="cursor: pointer;" class="subItem" id="maintenance-reboot"><span class="arrow"> </span><a>Reboot</a></li>
I tried
driver.FindElement(By.LinkText("Reboot")).Click();
I also tried with id "maintenance-reboot" but nothing work for me.
Then I try to go directly link.
http://192.168.1.1/pages/maintenance/reboot/reboot.html
page came but no frame only reboot page and I clicked button but nothing change.
I think the mainframe required for reboot.
try this 3 things:
driver.FindElement(By.Xpath(".//li[#id='maintenance-reboot']/a")).Click();
or
driver.FindElement(By.Xpath(".//a[contains(text(),'Reboot')]/..")).Click();
or
driver.FindElement(By.Xpath(".//a[contains(text(),'Reboot')]/../..")).Click();
one of them must work for you
Alter solution: go to the page and execute Javascript "btnReset();"
((JavascriptExecutor) driver).executeScript("btnReset();");
Related
I am trying to automate a download function from a broker. I have been able to logon with id and pw, navigate to specific web pages, and select and collect items from the site. I am stumped, however, on how to select an ARIA:Listbox item in an embedded form. All the examples I have seen show windows forms listbox or HTML select lists which is not the way this www site is built.
I have been successful with the c# Selenium findelement By.ID for the listbox required, but the last error said it must be scrolled into view. I'm guessing that the item is not in view because I haven't got the ARIA Listbox click to work to display the list. I've tried clicking on the dropdown arrow, and on the cell itself but the list doesn't show up.
I need some pointers on what to try next.
Thanks
OK - here's some additional info:
I apologize if this doesn't present right - I'm just learning to use the site...
When I use the program code
browser_driver.FindElement(By.Name("OfxDownloadForm:downloadOption")).Click();
I get the message
OpenQA.Selenium.ElementNotInteractableException: 'Element could not be scrolled into view'
The relevant html follows:
<span id="OfxDownloadForm:downloadOption" role="presentation" onfocusjs="removingDuplicateContentFromMenu();;vg.validation.focus(this)" onchangejs="setWarnings('downloadOption');" onblurjs="vg.validation.blur(this)" class="vg-SelOneMenu" compname="selectOneMenu">
<div class="vg-SelOneMenuCont vg-SelOneMenuNoWrap vg-SelOneMenuFocusText vg-SelOneMenuHover" id="OfxDownloadForm:downloadOption_cont" aria-owns="menu-OfxDownloadForm:downloadOption">
<a href="javascript:void(0);" onclick="return false;" class="vg-SelOneMenuTrigger" id="OfxDownloadForm:downloadOption_aTag" role="button" aria-xpanded="false" aria-haspopup="true" aria-controls="menu-OfxDownloadForm:downloadOption" aria-labelledby="downLoadOptionText OfxDownloadForm:downloadOption_text" aria-disabled="false">
If I go after "OfxDownloadForm:downloadOption_aTag" with:
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.PresenceOfAllElementsLocatedBy(By.ID("OfxDownloadForm:downloadOption_aTag")));
browser_driver.FindElement(By.ID("OfxDownloadForm:downloadOption_aTag")).Click();
Nothing happens - the popup doesn't occur.
Hope this comes out ok!
After much research and reading, I figured out that I had to do a two step action in the program:
input_element = browser_driver.FindElement(By.Id("OfxDownloadForm:downloadOption_aTag"));
Actions actions = new Actions(browser_driver);
actions.MoveToElement(input_element);
actions.Perform();
input_element.Click();
I believe the FindElement method just located the element, but didn't reposition the mouse into the document on that element. MoveToElement method scrolled down the document and brought the element into the view, and then a click on the same element allowed the drop-down listbox to do its processing. Once I did the find and the move, I was able to select the appropriate dropdown item.
I've been searching for an answer to this but haven't found what I'm looking for yet.
When I load into the page there is a check run one the server side. Depending on the output of this (bool), I wish to display a "yes no" confirm box to execute another piece of server side code.
I have found ways to do this easily enough on a button click but I'm trying to avoid adding a hidden button and simulating a click.
MessageBox.Show isn't an option in this case as I get the following error:
Showing a modal dialog box or form when the application is not running
in UserInteractive mode is not a valid operation
Is there any way to achieve this without simulating a button click?
Cheers,
Spitfire2k6
In web app (including the one created with ASP.NET) you can use Javascript confirmation dialog box: window.confirm("Request to Confirm Text");, and process User's response like in the following sample code snippet:
var _response = confirm("Please Confirm");
if (_response == true) {//Do Action1}
else {//Do Action1}
Pertinent to your case, you can use for e.g. page <body onload> event. Hope this may help.
I realised I was going about this all wrong.
The check is now done on page load, depending on the result I'm showing an asp panel with 2 asp buttons as a confirm box.
Thanks for all guidance.
Cheers,
Spitfire2k6
There's no easy way to explain this but, I have a website, that links to a online game I've made using asp C#. The website has a link to the game so when the user clicks the link on the site, my game pops up! Simples...
But I want it to pop up in a new Window! but not a browser window... Just... A Window :s
for Example, if you go on www.dofutoshiki.com and click on the "Play Futoshiki in our online player" link, it opens a new window with, just the game. No browser functionality.
I was wondering if anybody out there could shed some light on the subject...
Ive Tried:
Click me!
but it just opens a new tab in the browser!
Thanks!
Alex
If I get this right, you actually want a browser window but without the chrome/UI.
For this, you need to use window.open() (javascript) rather than a target attribute.
http://www.pageresource.com/jscript/jwinopen.htm will help you.
You have to open the new window by using javascript and disabling the unwanted functionality by passing arguments.
You will probably need some javascript for this. What you need to look in to is the
'window.open(...)' function.
Here are a few examples.
And here you can play around with it.
Use javascript Window.open method
Click me!
<script>
function openGame(){
window.open(blahblah.aspx,'Play Game','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=n o,menubar=no,status=no,resizable=yes');
}
</script>
You can use Jquery popup window plugin it is easy to use and more flexible also.
http://swip.codylindley.com/popupWindowDemo.html
On site you are referring to, browser window is opened. It's configured so that it does not have toolbar, status bar, menu bar, etc.
You can take a look at window opening code in HTML source of the page you are referring to:
<a onClick="window.open(this,'playsample','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,status=no,resizable=yes');return false;">
Is javascript an option?
With javascript it would be something like this:
<a href="#" onclick="window.open('blahblah.aspx', 'game','status=0,toolbar=0,width:400,height:300');" > Click here for the game! </a>
Use this
Click me!
Or even better, put the onclick code in a function of your own so you can reuse it.
i have an asp.net website where thers an apply button and the webpage uses microsoft sql. The problem is that when the user clicks the apply button for a very long time right about 80-100 times, the webpage usually seems to lose connection and takes forever trying to load the page, and then either says a connection is close or timeout error.
Any ideas? Only happens if the user clicks the apply button for a very long time, but if i wait for like 2-5 mins and reopen the browser, everything works fine again
Do you want the functionality by which use can click the button twice. Why don't you think of disabling the button once it is clicked and update the text to 'Processing.....'
You can do as follows...
Considering you have a button with ID="ButtonProcess" runat="server"
Add the script as following
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('input[id*=ButtonProcess]').click(function() {
//Your logic goes here to change text, do validation, bla bla bla.....
$('input[id*=ButtonProcess]').attr('className', 'processbookingbutton');
$('input[id*=ButtonProcess]').attr('disabled', 'disabled');
});
});
</script>
So, disabling the button and replacing the text with "Processing....." gives the user indication that you have already clicked the button and now wait for the output.
You can also use UpdatePanel and UpdateProgress controls to make it more user friendly.
Hope this helps....
Sounds like you aren't managing DbConnection properly. Show us your data access code, specifically how you are opening/closing connections.
I have an ASP.NET/C# application that exports some data into an Excel spreadsheet using COM interop at the click of a Button control. When I click the button, Excel is opened with the generated spreadsheet. For what it's worth, here is the button code:
<asp:Button ID="export" Text="Export to spreadsheet" runat="server" OnClick="Export_Workbook" />
This works fine, except when I click the button, close the subsequent spreadsheet, and refresh the page. When the page is refreshed after clicking the button, the call to Export_Workbook() is made again and so the spreadsheet opens again. Firefox, for example, says this when you refresh: "To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier." This is something I want to avoid.
I'm sure there's a better way to accomplish what I'm trying to do, I'm just not sure what the best approach is.
Edit
I've accomplished this by doing the following:
protected void Export_Workbook(object sender, EventArgs e)
{
Response.Redirect(Request.Url.AbsolutePath, false);
ItemList.Prepare_Workbook();
}
Not a particularly elegant solution, but it works. I'm still open to suggestions.
You have to redirect back to the current page at some point at the end of the postback to prevent duplicate form submission. This is called the Post/Redirect/Get pattern.
I dont think there is a better way to do it, except to keep track of if it has been refreshed before, and just not call the content the second time you refresh it.