IWebElement advancedSearchButton = driver.FindElement(By.Id("advanced-search"));
advancedSearchButton.Click();
this code works when the click button is displayed in the chrome driver, but when I resize the chrome to a very small size and the button is not displayed on the browser but it is loaded, click action does not work. When I minimize the chrome, click action works I am confused what to do ? I want to eventually try to make chrome as small as possible to hide the detail from the user kind of trying to run headless with windows C# please help thank you
Related
I am trying to download csv file from below URL using Selenum webdriver.
nse bulk deals
screenshot nse bulk deals
I tried most of the ways to click "Get Data" button and it's clickable. This button is gets disabled only in chrome remote controlled mode but if we open the url in browser it works fine.
Is there a way to fix this problem ?
I'm trying to get Selenium to click on one of the most visited web links from the default Chrome web page.
The problem is that Selenium cannot find the element on the page and I think it has to do with the fact that a web page technically didn't get loaded. When you open up Chrome it has HTML elements there but the address bar is completely empty. I think possibly this is why Selenium can't find the link? The code is simple and finding the XPATH wasn't an issue. I just don't know if this is a function that Selenium will be able to do or not. I'm trying to do the click because the navigate() function will not work when I put in the proxy information due to the fact that Selenium doesn't have a built-in way to handle a proxy with username and password.
At the end of the day I'm trying to get the username/password box to pop up by clicking on the link. When I open the browser with Selenium programmatically and then manually click on the link the username/password box pops up. But I can't get Selenium to find the element to click on programmatically.
var did = driver.FindElement(By.XPath("//*[#id='mv-tiles']/a[1]"));
did.Click();
UPDATE 1:
I was able to find the element when taking into consideration the iframe but clicking still is an issue.
var frm = driver.SwitchTo().Frame("mv-single");
var did = frm.FindElement(By.XPath("//*[#id='mv-tiles']/a[1]"));
//did.Click(); <-- I can see it go to the element but nothing occurs
IJavaScriptExecutor js2 = (IJavaScriptExecutor) driver;
js2.ExecuteScript("arguments[0].click();", did);
The JavaScriptExecuter is able to click the element but Chrome blocks the redirect with the following message:
[21040:24704:1204/150143.743:ERROR:CONSOLE(1)] "Unsafe JavaScript attempt to initiate navigation for frame with URL 'chrome-search://local-ntp/local-ntp.html' from frame with URL 'chrome-search://most-visited/single.html?title=Most%20visited&removeTooltip=Don%27t%20show%20on%20this%20page&enableCustomLinks=1&addLink=Add%20shortcut&addLinkTooltip=Add%20shortcut&editLinkTooltip=Edit%20shortcut'. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor has it received a user gesture. See https://www.chromestatus.com/features/5851021045661696.
", source: (1)
FINAL UPDATE:
I gave up and decided to do the browser extension solution for proxies with passwords: https://stackoverflow.com/a/35293222/5415162
That list of "Most Recent Pages" is actually in an iframe, which is probably why Selenium can't find it. Try updating the selector to account for the iframe, or maybe add a wait clause to allow the iframe to finish loading.
Regardless of that solution, I don't think it will act any differently than just navigating to the target URL. So to fix your root problem have you tried setting the proxy details when creating the ChromeOptions?
I did Process.Start(CHROME) to run Google Chrome browser.
However, I need to get the emelemt ID so I can do click.
Example:
I launch Google Chrome, it will navigate to some URL I tell it, and it will get the elementId of the button and will click it
I don't have any code to show, because I don't know how to do it.
I have a <button> element. I call the click() function on this element using chrome webdriver.
appDone = driver.FindElement(By.Id(Constants.APP_DONE));
appDone.Click();
A strange thing happens in chrome, the page actually get reloaded. A pop up comes
"Are you sure you want to leave the page? You have unsaved data" Leave/Stay (buttons)
But same click event works fine in other browsers (Edge, IE, Edge). I opened the console in Chrome before clicking the button and placed debugger. Then executed the button click, the console window goes out a new console window comes up.
Anyone knows why this happens?
Things I have tried so far:
executed the button click using IJavaScriptExecutor
There is an beforeunload event in page, so when I pass onbeforeunload = null, I don't see the page refresh pop up anymore, but page still refreshes.
Tried to add type = button in the button, still no luck.
This screen works fine when run manually without Automation.
I have few logs recorded in server side, so when a page refresh happens, those logs are actually getting deleted, which should not happen.
I am working on a automation of a website using selenium and C# , but i stuck in a situation where on a button click a new webpage dialog open and on that web page dialog we have to select some value and click on save button. Problem is i am unable to switch to that webpage dialog and even f12 window not working on that webpage dialog this website is only working on IE so no other option . Please help me. Here is post screenshot of webpage dialog and HTML code of Button which open that dialog box.
I have got this problem, where the title of page is Webpage dialog same as you. In this window you can not inspect the element. Solution to this is go to
Internet Explorer-->
Internet Options -->
Security tab -->
Custom Level -->
Disable the option : Allow Websites to open windows without address or status bar
Now, You can inspect element by F12 in IE. now, simply write all the selenium commands, you can also use JavaScriptExecutor for that, If you dialog box calls JavaScript.