I have a code where it is identifying the button but not able to click on it ,may be because it is not in view.If we scroll it clicks.Can selenium click which is out of view
If element is on the page but not on the screen, selenium should click it without problems. Maybe your button is not on page at time of click?
I think it depends on the library you are using. E.g. nightwatch tries to scroll the element into view before clicking
.click()
Suggest edits
Simulates a click event on the given DOM element. The element is scrolled into view if it is not already pointer-interactable. See the WebDriver specification for element interactability.
https://nightwatchjs.org/api/commands/#click
I believe Mink2Selenium does not.
but if the element is not reachable by scrolling, selenium will not be able to click it, same as a user would not be able to click it. What is good, because selenium is used to do as much as possible realistic tests
Related
I am not able to click on the button, how you can see on the picture. This menu is visible, when you click on Tabellen button in the main menu. It is working manually, but when I try my selenium code, it is not working. I try different type of select it, I tried also waits. I tried xpath, cssSelector, ID. What is strange, selenium just click Tabellen button from main menu, but that menu after that just blink and nothing happen.
Please use this example. You need to correct XPath if I have made a mistake.
driver.find_element_by_xpath('//*[text()="Tabellen"]').click()
time.sleep(5)
driver.find_element_by_xpath('//*[text()="Tabellen"]//*[text()="Standorte"]').click()
In the following ecommerce site "https://www.gittigidiyor.com/", I want to click on "giris yap" button using selenium java but the problem is whenever I hover the mouse to profile icon, this pop-up appears and i try to inspect the pop-up to see the element but nothing happened. Could you please help me how can i click the buttons of this pop-up. I tried by switching to alert/frame but it did not workopened login popup in the site
driver.get("https://www.gittigidiyor.com")
driver.findElement(By.cssSelector("[title=\"Giriş Yap\"]")).click()
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("[data-cy=\"header-login-button\"]"))).click();
To find the element use below technique:
To search xpath of such dynamic elements use DOM break points:
And select break on subtree modification. Now all changes will break and pause the webpage rendering
Click resume execution or press f8 till your span gets displayed
Has anyone had trouble using the selenium click function? Sometimes it cannot click on an element even though its visible. Sometimes it can click on an element that is underneath another element (that the user cannot click on). What's a good alternative?
I have a hidden div element that when I click the link the visibility changes. In my Selenium IDE script I click the link and I see the div open but then it immediately closes. The rest of the scripts run, but in a demo I would like to keep that div open.
My steps are:
click [Link that shows hidden div]
-->It is here that it displays and then immediately hides it.
focus [element inside div]
assertValue [target element]
Is there a setting that I need or a step that needs to be added?
It's hard to suggest. But there are some things that you can try.
First of all maybe your div is going to hide when link is not under
the mouse. Than you can use mouseOver
Maybe if you need just to verify variable you do not need even see
the div. Selenium IDE can take the value from element that is not
visible. It is not a fare play but sometimes you can do it.
Another way is to use javascript to bring your div to the light:
getEval | window.document.getElementById('your_divs_id').set_attribute('style','');
The most brutal and not trustable way to try to do it to add command
getEval | window.stop()
right after the click.
I'm testing AJAX app using selenium IDE and got many problems on scrolling page.
Some elements can't be interacted with until they are visible.
I saw some articles on web mentioned this can be done by click/mouseOver/focus on the locator but all not working for me.
however, the page does scrolled when I click "Find" button on Selenium IDE to find the locator..
is there any way to simulate the click of Find button?
any suggestions are appreciated, thanks.
It sounds like by visible, you mean actually finished loading. What you can do is for the element you want to interact with, put a command "waitForElementPresent" for the element:
waitForElementPresent | <elementid>
click | <elementid>
Thus, the test will wait for the element to be loaded before the interaction.
Klendathu