I can't click on element, because of overlay appears. Try to use capability to scroll to element and set it in bottom. Does not work for me.
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 1);
RemoteWebDriver driver = new ChromeDriver(options);
Can we do it in another way using java, chrome options (except js)?
chromedriver 2.36
selenium 3.11.0
testNG 6.14.2
If something overlays on top of the element you want to click then use actions method to move to the element which will make it enable to click and then click. This should work:
Actions actions1 = new Actions(driver);
actions1.moveToElement(youElement);
actions1.click();
actions1.build().perform();
Related
I am currently working in a selenium with java automation proyect.
The web page I am automating opens a side menu depending on the size of the screen. In my case, it does not open it. To solve this you can either clic on the menu button to open it or change the zoom.
I am trying to implement the second solution zooming (this is the solution I need):
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("document.body.style.zoom='70%'");
The zoom works but the side menu does not appear. Is there anything extra that I need to do?
I also use the next line as part of my configurations:
ChromeOptions options = new ChromeOptions();
options.addArguments("window-size=1980,1080");
I also tried different ways to zoom in but the results are the same:
driver.findElement(By.tagName("html")).sendKeys(Keys.CONTROL,Keys.SUBTRACT);
WebElement html = driver.findElement(By.tagName("html"));
new Actions(driver)
.sendKeys(html, Keys.CONTROL, Keys.SUBTRACT, Keys.NULL)
.perform();
Any suggestions? I would appreciate them because I am new to selenium and I am pretty stuck with this issue.
driver = new ChromeDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
driver.get("chrome://settings/");
jse.executeScript("chrome.settingsPrivate.setDefaultZoom(0.9);");
driver.get("...");
This is how I managed myself to do zoom correctly.
webDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();
Thread.sleep(2000);
driver.findElement(By.xpath("html/body/div[1]/section[1]/div/div/a/button")).submit();
'View positions' button is not clicking with the above code.What is happening in the web page?
You see the HTML for this page is
So, you can use the CSS selector for this as
WebDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();
Thread.sleep(2000);
driver.findElement(By.cssSelector("button.button.teal").click();
And then proceed with doing whatever is necessary. I executed with this in my Python code and it works fine.
Also, you will need to provide the Gecko executable path while calling for the FirefoxDriver()
The way I have done it before is to use the click handler.
driver.findElement(By.cssSelector(".profile-actions .primary_button > span")).click();
I'm sure you could also select the element by xpath rather than CSS in the above line. It's a similar question to this one.
I am using Java and Selenium to write tests for Chrome. Sometimes I need to get to chrome://downloads/ and click on CLEAR ALL button. I can get to the page by
RemoteWebDriver driver = (RemoteWebDriver) driverChrome;
driver.executeScript("window.open();");
Thread.sleep(500);
tabs = new ArrayList<String>(driverChrome.getWindowHandles());
driverChrome.switchTo().window(tabs.get(1));
Thread.sleep(500);
driverChrome.get("chrome://downloads/");
but I cannot click on the button, whatever xpath I use it says no such element
Below here JavascriptExecutor example to perform click on CLEAR ALL button using selenium :-
JavascriptExecutor executor = (JavascriptExecutor)driver
executor.executeScript("var dm = document.getElementsByTagName('downloads-manager')[0];var toolbar = dm.shadowRoot.getElementById('toolbar');var actions = toolbar.shadowRoot.getElementById('actions');actions.getElementsByClassName('clear-all')[0].click();");
Tested in Chrome Version 50.0.2661.102 m
Hope it will help you..:)
I try to select multiple options from list but it does not select particular option it select from first choose options to last choose option and give some error like:
Cannot perform native interaction: Could not get node for element - cannot interact
My code is looks like
WebDriver driver=new FirefoxDriver();
driver.get("http://jqueryui.com/selectable/");
driver.manage().window().maximize();
driver.switchTo().frame(driver.findElements(By.tagName("iframe")).get(0));
WebElement multiSelectDropDown=driver.findElement(By.className("ui-selectable"));
List<WebElement> dropdownlists = multiSelectDropDown.findElements(By.tagName("li"));
Actions builder=new Actions(driver);
builder.clickAndHold(dropdownlists.get(0)).
clickAndHold(dropdownlists.get(4)).click()
.build().perform();
Can any one tell me why this is not working is there any problem in my code.
I think you need to change this
builder.clickAndHold(dropdownlists.get(0)).
clickAndHold(dropdownlists.get(4)).click()
.build().perform();
This should be looks like
builder.clickAndHold(dropdownlists.get(0)).moveToElement(dropdownlists.get(4)).
release().build().perform();
because in real world click the mouse and drag to the other element so moveto another element and then release the mouse.
I am using FirefoxDriver webdriver. The page that loads in Firefox window is a large page and I want to scroll that page using selenium.
I want to know how this can be done.
If you want to scroll on the firefox window using selenium webdriver, one of the way is to use javaScript in the java code, The javeScript code to scroll down is as follows:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," + "document.body.scrollHeight,document.documentElement.clientHeight));");
I think you should do something like
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
Good Luck.
Use this code to scroll single page down
Actions actions = new Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();
page.driver.browser.mouse.move_to( find("element").native,100,100)