I have a dropdown menu sub-item ("logout") that I want to select. I need to hover over the menu first to make the logout link appear. There's a lot of div's surrounding it; the spy tells me it's an HTMLPANE, but there's no built-in support for HtmlPanes in VS code as far as I can see. (I try typing it in and intellisense doesnt recognize it, not from htmlcontrols namespace)
Just before trying to describe this main menu object, I'm defining the variable as an HtmlDiv. I've even tried to identify it generically by referring to it as an HtmlControl.
Here's the "view source" of the dropdown menu in question. I need to get to the "Logout" link which is the bottom option in the dropdown.
<li class="my-account-top" aria-haspopup="true" aria-owns="doormat-profile">
<span class="icon-profile menu"></span>
<span class="profile-header tablet-hide"> Profile</span>
<div class="ma-menu-items left">
<a id="nav-my-account-profile" href="/my-account/profile/">Edit Profile</a>
<a id="nav-my-account-profile-view-card" href="/my-account/profile/view-card/">View ID Card</a>
<a id="nav-my-account-profile-request-card" href="/my-account/profile/request-card/">Request ID Card</a>
<a id="nav-my-account-profile-logoff" href="/my-account/profile/logoff/">Log Out</a>
</div>
</li>
</ul>
I'm not familiar with the `mouse.hover function. Can you please show me an actual example, preferably from this code? I'm not even sure if this is a way to identify it because from what I observed by recording the hover, browser resizing changes the coordinates.
I don't know if I am obliged to give a coordinate to mouse.hover, or can I just specify the name of the object control? (i.e. mouse.hover(varnameformainmenu))
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'm running into trouble with Selenium when it comes to XING's groups. The solution I was using for more than two years to this very date does not work anymore; they must have changed something about their HTML.
The main problem is that a certain select element doesn't open (when trying to open it by clicking it) and I hence cannot access the options to "click" or to select. I see a small border embracing the drop down, as if it was clicked but didn't function in second place.
Now that I've spent quite some time on elaborating on the error, I'm quite sure this is because the same (meaning the same attributes, ...) drop down exists on the same page at another point (to sort/filter posts shown by groups). However, I want to select the (sub) forum that a new post is submitted to, and this does not work.
I tried many, many, many different things of which none worked, obviously. I'm unable to list all of my attempts here since it's simply too much and partly too long ago. Some of what I tried:
select the drop down by various methods (CSS Selector, class name, XPath, ...)
access the desired option of the drop down directly (by CSS Selector, class name, XPath; even tried to collect arrays of all elements and select the right one by index, didn't work either)
access the desired option of the drop down directly by JavaScript and 'click' it by JS
And now SO is my hope. I thought of a way to select -exactly- this drop down (rather than the other one described) by child elements and so on (this is the reason for the title of this question).
This is the HTML:
<div class="comm-navigation forum-select is-open" id="new-post-forum-select" data-is-open="true">
<a href="#" class="comm-navigation-trigger">
<span class="comm-navigation-name" title="Select forum">Select forum</span>
<i class="comm-navigation-icn-closed foundation-icon-shape-arrow-down"></i>
<i class="comm-navigation-icn-open foundation-icon-shape-arrow-up"></i>
</a>
<ul class="comm-navigation-dropdown hidden" style="width: 519px; display: block;">
<li class="comm-navigation-group forum-list">
<ul>
<li class="comm-navigation-item">
<a href="/communities/forums/100941274" class="comm-navigation-forum" data-forum-id="100941274" data-forum-name="Members" title="Members">
Members
</a>
</li>
<li class="comm-navigation-item">
<a href="/communities/forums/100941276" class="comm-navigation-forum" data-forum-id="100941276" data-forum-name="Q & A" title="Q & A">
Q & A
</a>
</li>
<li class="comm-navigation-item">
<a href="/communities/forums/100941275" class="comm-navigation-forum" data-forum-id="100941275" data-forum-name="Feedback" title="Feedback">
Feedback
</a>
</li>
</ul>
</li>
</ul>
<input type="hidden" name="post[forum_id]" id="post_forum_id" value="">
</div>
I thought of perhaps going from comm-navigation forum-select is-open (which is the same when it's still closed without is-open) to the inner elements to get the right Chrome element and then click the option.
Also, I found that there's a hidden field:
<input type="hidden" name="post[forum_id]" id="post_forum_id" value="">
Which is exactly related to my problem; value is empty as long as nothing's selected, as soon as selected, the forum's id is inserted into the value. This I could imagine if there wasn't any JS that prevents you from submitting the form without having actually selected the sub forums by drop down.
Looking forward to great solutions.
If I understood the question, then first you need to click on the span inside the first link (class=comm-navigation-trigger) with the text "Select Forum". This makes the "ul" below to be visible. Now you need to click the desired "li" inside this list. If so then read on.
Find the span with the css selector - "div[id='new-post-forum-select'] > a[class='comm-navigation-trigger'] > span". Click on this element.
Wait for the list to become visible. Use the css selector - "div[id='new-post-forum-select'] > ul[class*='comm-navigation-dropdown']". Use the ElementIsVisible ExpectedCondition. Though you may or not require this step, added this as a check.
Find the link with the required value - "div[id='new-post-forum-select'] > ul[class*='comm-navigation-dropdown'] a[class='comm-navigation-forum'][data-forum-name='Q & A']". Click on this.
I am currently working on a form. In the form, if there is not an item needed you can click the add button and it takes you to a new form where you can add the item. Instead of my view going to another page, I want it to pop up above the form so that the user can just quickly add the item and not have to travel pages.
Here is a snipit from my Create.cshtml
<div class="form-group">
<label asp-for="INT_CertificationsID" class="col-md-2 control-label"></label>
<div class="col-md-3">
<select asp-for="INT_CertificationsID" class ="form-control" asp-items="ViewBag.INT_CertificationsID"></select>
</div>
<a class="btn btn-default" asp-area="" asp-controller="INT_Certifications" asp-action="Create">Add Certification</></a>
</div>
When the add certification attribute is clicked I would like a box to pop up to the Create.cshtml for the certification. So that they may quickly add it to the list and continue to fill out the form.
I have looked up several examples to do this but most of them are either too old, too long, or don't work in .netcore due to nuget package errors with JqueryUI.
You need to make a controller method that returns the page you want in the popup as a PartialView.
I think you mean modal and not "popup"... you need to use a modal mechanism to create a modal window and get (or post) your partial via AJAX and use the result to display in the modal window.
I like bootbox which is a wrapper for bootstraps modal functionality.
I would load partial view in a hidden div together with the pages that needs them and dynamically display them with JavaScript when needed. Don't use forms to send http request, instead use AJAX.
Using pop-ups can work against you because browsers comes by default with pop-up blockers. Might work on your devbox but it could have a completely different behaviour somewhere else.
Using forms to send request requires the page to be reloaded which does not provide a good user experience.
Fix your solution, don't use nugget for client side script. Use bower instead. Here's a link https://learn.microsoft.com/en-us/aspnet/core/client-side/
I am trying to create a proper XPATH syntax in C# to click on a download button from the Amazon business website. Everything I have tried is unable to find the button. Here are some of the things I've tried:
driver.FindElement(By.XPath("//button[#type='submit']")).Submit();
driver.FindElement(By.XPath("//span[contains(#class,'a-button-inner')][contains(text(),'downloadCSV_button-announce')]")).Submit();
driver.FindElement(By.XPath("//span[contains(#class,'a-button-inner')][contains(text(),'Download CSV')]")).Submit();
Below is the source code from the Amazon page. Can anyone help me to design the proper XPATH query to click this download button? Thank you.
<h1>Amazon Business Analytics</h1>
<div class="a-row a-spacing-medium a-grid-vertical-align a-grid-center">
<div class="a-column a-span12">
<span class="a-declarative" data-action="aba:download-csv" data-aba:download-csv="{}">
<span id="downloadCSV_button" class="a-button aok-float-right"><span class="a-button-inner"><input class="a-button-input" type="submit" aria-labelledby="downloadCSV_button-announce"><span id="downloadCSV_button-announce" class="a-button-text" aria-hidden="true">Download CSV</span></span></span>
</span>
You should try using WebElement#click() to perform click on element instead as below :-
driver.FindElement(By.CssSelector("input.a-button-input[aria-labelledby = 'downloadCSV_button-announce']")).Click();
Or if span element is clickable try as :-
driver.FindElement(By.Id("downloadCSV_button-announce")).Click();
Or
driver.FindElement(By.Id("downloadCSV_button")).Click();
I am using the jQuery plug in contentcarousel. It is a good plugin and all but I need the ability to dynamically create a certain number divs according to the user.
To achieve this I am using an <asp:panel> and then running a Literal & foreach in C# to populate the panel. The problem comes in when the <asp:panel> is used.
It seems as if the jQuery plugin can only work if the divs occur in a certain order.
ie.
<div id="ca-container" class="ca-container">
<div class="cawrapper">
<div class="ca-item ca-item-2">
<div class="ca-item-main">
When the panel is used, then the order becomes
<div id="ca-container" class="ca-container">
<div class="cawrapper">
<div id="panelinfo">
<div class="ca-item ca-item-2">
<div class="ca-item-main">
And the plugin stops working. At least I am assuming so due to the fact that the arrows dont show up, none of the buttons work, etc.
Does anyone know if there is a way around this? Maybe a way to "hide" the div that the panel becomes?
It sounds like you want to have a control that acts like a Panel in server side code, but instead of being rendered as a div just plops all of whatever would have been inside of it without adding anything "extra". That's pretty much the definition of an asp:Placeholder. Just use that instead of a Panel.
Try moving your JQuery code into window.load. I'm assuming you have your jquery in document.ready which will fire the second the dom is ready.
$(window).load(function(){/*Your code*/}