c # I am preparing a selenium project. I made a cross browser on the project, but I'm having trouble with internet explorer 11. Locators working correctly in all other browsers also work incorrectly in the intertet explorer.
selenium 3,12
ie version 11.431.16299.00
https://drive.google.com/open?id=1QhEsm9cIVNVRi0c37_L3mRc17mbXgR1m
Locator I have used : By.CssSelector("a.login-button.primary-action");
HTML :
</nav>
<nav class="login-navigation active">
Teklif Al
<nav class="login-menu">
Giriş Yap
<nav class="login-menu-list">
Yönetici Girişi
Kullanıcı Girişi
</nav>
</nav>
</nav>
According to official selenium documentation:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
For Windows 10, you also need to set "Change the size of text, apps, and other items" to 100% in display settings.
Also in "Hovering Elements" section there is a warning:
When you attempt to hover over elements, and your physical mouse cursor is within the boundaries of the IE browser window, the hover will not work.
If you take into account these configurations, it will work.
Try this code :
Driver.FindElement(By.LinkText("Giriş Yap"));
Try this
By.CssSelector(".login-button");
or
By.CssSelector("html body nav.login-navigation.active nav.login-menu a.login-button.primary-action");
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 puzzling at this for a few hours now. Checked through similar issues on Stackoverflow but been unable to find a solution.
I have a checkbox I'm trying to use Selenium webdriver to check, but when I run the script, I don't get any error messages but the checkbox remains unchecked.
I'm using the line below to select and check the box
IWebElement checkBox = m_driver.FindElement(By.XPath("//div[2]/label/span"));
checkBox.Click();
I've copied the HTML from it below.
<div class="input-group single-option label-empty" >
<label class="" >
<input type="checkbox" name="privacy" value="true" required />
<span>I have read and understood the <a data-toggle="#privacy-terms"
data-group="privacy-terms">Privacy Policy</a> and <a data-toggle=
"#terms" data-group="privacy-terms">Terms and Conditions</a>. </span>
</label>
I'd really be grateful for some help. I'm pretty new to automation...and C#
Unfortunately, I am unable to post the url as it's a passworded client site. If I can post the HTML, that may help...
I've posted the html from the page in question but removed the client name :)
Link to HTML
If I select the checkbox through Chrome developer tools and copy the Xpath, I get this.
IWebElement checkBox = m_driver.FindElement(By.XPath("/html/body/div[1]/main/section/form/div[2]/label/input"));
I re-ran it and Selenium generated an error.
Message: OpenQA.Selenium.WebDriverException : unknown error: Element
is not
clickable at point (491, 593). Other element would receive the click:
... (Session info: chrome=71.0.3578.98) (Driver info:
chromedriver=2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT
10.0.17134 x86_64)
developer tools
Here is a screenshot of developer tools with the checkbox ticked. Could it be something to do with the 'span'?
You are clicking the SPAN not the INPUT that is the checkbox. This should work.
m_driver.FindElement(By.CssSelector("input[name='privacy']")).Click();
You may need a wait, depending on what is going on before the click.
Your error about element is not clickable could be any number of things. It could be popup blocking it, a floating DIV panel, a loading spinner, ... etc. You will need to deal with the popup (by closing it, etc.), floating DIV may require the page to be scrolled, or for the spinner a wait for the spinner to become invisible. It's hard to say without more information.
I figured it out. Instead of using "checkBox.Click();", I used "checkBox.SendKeys(Keys.Space);
and it works. Now I'm trying to do the same with the recaptcha which by definition should be difficult.
I have a C# Windows Forms Application with a webBrowser within it. It visits a Wikia chatroom, where it then locates the element which contains the chat output. This element looks like:
<div style="" id="Chat_XXXXX" class="Chat">
<ul>
(chat text)
</ul>
</div>
The purpose of the program is to retrieve the chat text every once in a while for logging purposes. This is easily done by parsing the "InnerHtml" of the "Chat_XXXXX" element. However, I also need to clear the text from the window when I do this (for various reasons, I cannot leave the text in the window). I figured I would just erase the chat text portion of the element, as this is how it is done with a handy javascript file called "chat hacks" for Wiki chat (here). Or at least, I think that's how it does it. If you look at the function "clearWindow" in that file, you can see what it does:
NodeChatController.prototype.clearWindow = function() {
this.viewDiscussion.chatUL.html('');
this.inlineAlert(i18n['cleared']);
}
I have tried setting the InnerHtml of "Chat_XXXXX" using the following three strings (not all at the same time, of course):
HtmlDocument document = webBrowser1.Document;
document.GetElementById("Chat_XXXXX").InnerHtml = ""
document.GetElementById("Chat_XXXXX").InnerHtml = "<ul></ul>"
document.GetElementById("Chat_XXXXX").InnerHtml = "<ul><li class=\"inline-alert\"> Window cleared. </li></ul>"
However, although these clear the window (and in the case of the last one prints a message), the chat no longer updates as new messages show up. The only fix is to reload the page, which isn't an option, because reloading the page brings in a whole load of chat history (which I'm trying to avoid). I've also tried importing that javascript mentioned above into the page using:
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
scriptEl.SetAttribute("type", "text/javascript");
scriptEl.SetAttribute("src", "https://db.tt/66q8UQbY");
head.AppendChild(scriptEl);
This javascript creates a button which clears the chat window. The button clears the window just fine, but again, the chat no longer updates. I know this button works correctly without stopping further incoming chat in "regular" browsers (Chrome, Firefox, Opera, etc). I've used it many times, and the script itself is quite popular in the Wikia community. I've already followed the steps here: "WPF WebBrowser Control - position:fixed Element jumps while scrolling (Windows 8)" to get the browser to act as close as it can (?) to Internet Explorer. I've already checked the Body field of the document after altering the InnerHtml to make sure that my replacements didn't alter anything important. Just for clarity, here's an example of what is contained in the (chat text) portion of my original example:
<li class="you" data-user="UserNameHere" id="entry-c812">
...avatars and junk...
<span class="message">hello</span>
</li>
I honestly have no idea what could be causing the chat element to stop updating after it has been edited (especially since it works outside of this program), so I don't know what information to include. Whatever you need, I'll provide it. Here's the javascript from Wikia which generates the chat output window: chat_js2. Look for "Chat_" to find the part which originally generates the window. I don't know where the output is updated in that file though.
In my Silverlight application I need to permanently disable the browser scroll bar. When I run the application the browser scroll bar is visible. So I need to disable this one.
Please let me know in which file we should do and the code for disabling the scroll bar.
u have to make your UserControle(root userControle) smaller that fit-up in to your browser that's way your browser scroll bar can disable.....
use silverlight navigation template
When using the default aspx-page to display the Silverlight application (the one generated by Visual Studio) usually no scroll bars should appear. But if that is the case that's the place where to look.
Sometimes the browser (especially the Internet Explorer) renders line breaks where there are none. So try to remove any line-breaks from the HTML-markup surrounding the <object>-element hosting the Silverlight application.
Example: Convert the following code
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
</object>
<iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
</form>
to the following code by removing all linebreaks (I added the ... to make the code more readable here, leave the original parameters there of course)
<form ...><div><object ...></object><iframe ...></iframe></div></form>
In my case that did solve the issue.
I've got this DIV tag that has a class definition in it.
<div class="clear hideSkiplink">
I've searched the entire project, but I can't find this class anywhere by using the text search feature.
Currently, the DIV is too wide, and I need to trim it down a bit.
Whenever I remove the class="clear hideSkiplink" reference, the DIV tag immediately grows much too large.
I inherited this project after the website developer left. I'm good with C# and WinForms, but not really this web stuff.
Could someone help me out, please?
Solved!
I found .clear { clear: both; } burried in the file StyleSheet.css, but I could not find the hideSkiplink word anywhere in my project.
So, I took the hideSkiplink word off, and the rendered page did not change in the browser.
Apparently, all I was seeing was controlled by the one clear word in the DIV tag.
My tag now reads:
<div class="clear">
Thanks, JLevett!
'clear' and 'hideSkiplink' are too different classes, not one.
Try searching for those individual phrases within your project.
if you have firebug, go to HTML tab, find your element and click on int, I made you a screen of this page as an example, the red circles show the class names and the green circles show you the css source file. You might as well ctrl+click on the source files and they open in a new browser window :)