I try to click on an element, which opens an windows model (choose a file..).
When I try to click on this button, no upload button is opened (But when I click on it manually it opens. Also, I see WebDriver success to find the element - the button is marked, but no window is opened.)
I try the next, none of them works:
1. currentPopup.click();
2. new Actions(driver).click(currentPopup).perform();
3. JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", currentPopup);
Do not click that button. Selenium does not popup the windows open file.
The work around is
driver.findElement(By.id("UploadElementID")).sendKeys("<absolutePathToFile>");
UploadElementID is the id of that element (input type="file") and in sendKeys you have to specify the absolute path of the content you want to upload (Image,video etc). Selenium will do the rest for you
Related
enter image description hereThere is a scenario that I am trying to automate through selenium webdriver (Java) and facing trouble. Print preview is not accessible through selenium as it is within shadow-root. Our task is to download the pdf files from web portals. When we clicked on print button on web, print preview window is opened and we need to click on save button in this print preview window in order to download the pdf. And also linked the URLs of the solutions that I have tried to solve this problem. for screenshot enter image description here
https://www.seleniumeasy.com/selenium-tutorials/accessing-shadow-dom-elements-with-webdriver
How to interact with the elements within #shadow-root (open) while Clearing Browsing Data of Chrome Browser using cssSelector
Handle Print Preview window using selenium in chrome latest version
How can I tell Selenium to press cancel on a print popup?
Selenium how to click Ctrl + p
How to click on the print button on a web page using Selenium
Try with mouse / keyboard actions libraries :
Library pyautogui
Library ImageHorizonLibrary
Check keywords :
pyautogui.Key Down 'enter'
ImageHorizonLibrary.Press Combination Key.enter
The above libraries have additional keywords that should help.
I want to click on the element which is moving on webpage. How can I click on it?
I am using webdriver io
I have selenium.support version 3.141.0, chrome driver version 2.43.0 and Google Chrome version 71.0.3578.98 and Selenium.ChromeDriver.dll 2.43.0.
when i click on a certain button a new window should be open. i click on the button and if i use any action on the browser for example new WebDriverWait(_driver, TimeSpan.FromSeconds(60)).Until(IsPageLoaded); the window stop to load and stay blank data. why can't i get the browser to load it's content?
Edit: when the new window opens i change the the driver to the latest windowHandel and use the webDriverWait from above to wait which result in a blank data window, but if i use thread.sleep after changing the windowHandel the window load its content
You can try with a explicit wait for a element to be visible on the new window. That would ensure it waits for the contents to load up
I have a scenario where i need to right click on a link, when context menu appears i need to click on option "Open link in incognito window".
When i try to achieve this by below code snippet i could see a context menu appears but instead of launching the link in new window the link gets launched in same window.
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.google.com/");
Actions action = new Actions(driver);
WebElement ele = driver.findElement(By.linkText("About"));
action.contextClick(ele).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).perform();
any suggestions how to make this happen?
There may be a keyboard shortcut for opening a link in an incognito window but I was unable to find one but I didn't look for long. You may have better luck.
Another method would be to grab the URL of the link you want to click, open an incognito window using the keyboard shortcut (CTRL+SHIFT+N), and then navigating to the URL. It's not ideal but I don't know of another way to do this.
Is there some reason you can't just start your script in an incognito window and proceed from there?
This context menu is not a part of html page, but this is a menu coming from Chrome (a desktop application)
Selenium/WebDriver does not have the capability to automate the desktop applications, you can use AutoIt or similar software to do it
But all what you need is just to open a new browser session (incognito window is nothing but a new, independent browser session).
To simulate this behaviour using WebDriver just open a new Chrome driver:
WebDriver drv1 = new ChromeDriver();
drv1.get("https://www.google.pl");
drv1.findElement(By.name("q")).sendKeys("About");
........
........
// This will open a new browser window with a new, independent browser session
WebDriver drv2 = new ChromeDriver();
drv2.get("https://www.google.pl");
drv2.findElement(By.name("q")).sendKeys("Hello");
........
........
drv1.do-Something-in-session-1
.....
drv2.do-Something-other-in-session-2
....
My scenario:
1. Click on the Forgot username and password
2. Input wrong user ID and press tab.
3. Modal dialog appears with wrong ID text.
4. Accept the alert
Expected behavior:
Focus should be on the user ID text box.
Actual behavior:
In IE11- Through automation and manual the focus is on the userID text box.
In Chrome - Manual execution the focus is on the user ID textbox. But through automation the focus is on 'Ok' button(some other button in the page).
Why there is such a difference in behavior?
Selenium WebDriver-2.53.0
Chrome-49.0
You can use JavascriptExecutor as below:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('elementid').focus();");
Hope it will help you :)