Summary of the issue:
I have no idea if this is an Alert, but it sure looks like one.
Ways of closing the screen manually: Enter, Escape, Cancel, Sign In
note: The username input is selected the moment we arrive on the page so for me it is safe to assume we are in the correct element. I also include the inspect element result, which is completely empty.
Attempted code:
Press Enter Key: Press Keys NONE \ue007
Press Escape Key: Press Keys NONE \ue00c
Handle Alert: Handle Alert DISMISS --> Alert not found in 5s (there is a sleep before this just so I know 100% sure the 'alert' is loaded.
Google suggests that these things are often inside an iFrame and I have to select it first. I however have no clue how to figure out if it is inside an iFrame or what the identifier would be.
alert_img
Related
I have a webpage which I'm trying to fully load with clicking on its "Load More" button. However, even though I'm waiting for both the visibility and the clickability of it, selenium still clicks on the wrong element sometimes, before the Load More button comes to vision, completely opening a new tab as a result. My understanding is that its trying to click on wherever the button would've been if it was scrolled down to it successfully.
The piece of looped code that is trying to get the button and clicks it is down below:
val loadMoreButtonClassifier = By.className(ScraperConstants.LOAD_MORE_BUTTON_HTML_CLASS)
val executor = driver as JavascriptExecutor
while (true) {
loadMoreButton = driver.findElement(loadMoreButtonClassifier)
executor.executeScript("arguments[0].scrollIntoView(true);", loadMoreButton)
wait.until(ExpectedConditions.visibilityOfElementLocated(loadMoreButtonClassifier))
wait.until(ExpectedConditions.elementToBeClickable(loadMoreButtonClassifier))
loadMoreButton.click()
}
(I know it is a while true loop. It is surrounded by a try-catch to end it with not finding the button. It is only there to see if the logic works and I'll change the implementation afterwards to a better one, hopefully a better one.)
Before using executor.executeScript("arguments[0].scrollIntoView(true);", loadMoreButton) I was trying to move to the button via actions.moveToElement(loadMoreButton).perform() which ended up doing the same. I have also tried only checking the visibility and clickability separately, and thought maybe both needed to be asserted before a click is tried, but of course there are no changes between the two methodologies there too. I am out of options except an implicit wait which I do not want to do since it isn't a good practice at all. Is there anything I'm missing here?
EDIT: Solved it with executing javascript to find and click the button
I am trying to conditionally render an input bar that appears above the keyboard when the user is tying. I do not want to show this input bar unless the user wants to add something. So they tap a button which is supposed to make the component visible and then focus on the input which brings up the keyboard.
This works as expected except when the user first opens the keyboard. Nothing appears. There is an empty view tag as the keyboard comes up but then it disappears and there is nothing. However, once the user starts typing it appears and after that works as expected. I have no idea why it isn’t appearing. If I don’t type anything and dismiss the keyboard you can see it briefly before it goes away as it is supposed to.
I have tried calling the function with async-await and my current syntax. Neither is working and I have been unable to solve this.
Here is a snack that recreates the issue and contains all the relevant code to reproduce the error.
https://snack.expo.io/#dmargulies/inputaccessoryview-problem
Thank you for your help.
First of all InputAccessoryView exists only on IOS.
I changed conditional rendering flow.
Look at: https://snack.expo.io/#djalik/inputaccessoryview-problem
For anyone looking for a cross-platform solution, there is a package:
react-native-keyboard-accessory
Note: I'm not the author, just figured it might help some peeps.
There is a requirement like verifying Text using selenium on Popup notification before vanishing.
Not find any suitable solution for this.Please help me in this use-case
You can use the below code to get text from popup after that you can assert with the expected text
String value =driver.switchTo().alert().getText();
it is really unpredictable to understand your scenario.We must need pop-up HTML and a screenshot, and what problem you are facing.Sometime the pop up might be bootstrap modal or alert, so without knowing the popup, it is not possible to give the solution.Besides you can try simply find the element and use getText() function.If it is simple modal(Bootstrap), it will give you the text.
If you are struggling to find the element you can pause the JavaScript by using F8.
I'm looking for an opportunity to send "Enter" key to browser window, not to web element(to confirm the appearing save dialog). Is it possible?
This is in python, but other language will be similar. You should be able to use driver.switch_to.alert when the alert appears, which returns the alert object. If you just want to confirm the alert, use driver.switch_to.alert.accept(). Sending the enter key would be:
from selenium.webdriver.common.keys import Keys
# Get to stage where alert appears
# Send enter key
driver.switch_to.alert.send_keys(Keys.ENTER)
You may need to use Expected Conditions to wait for the alert to actually appear.
My scenario is that I have 2 windows, and the 2nd one shows an alert dialog of which I wanna check it's text.
Now I switch my WebDriver to the second window via:
driver.switchTo().window(driver.getWindowHandles().iterator().next())
And then to make sure I get the correct Alert handle I use:
Alert alert = ExpectedConditions.alertIsPresent().apply(driver);
String text = alert.getText();
but text is null even though the alert clearly contains a lot of text.
I then tried to use
String text = driver.switchTo().alert().getText();
but it also returns null.
Anybody of you encountered this problem?
I have another alert dialog I'm checking but that test runs smooth, so I
guess it's related to my 2 windows, found a smiliar post in webdriver Google
Group but nobody has replied to it. I also tried to close the other window
and then check for the alert, but same result. The alert is present and
recognized, otherwise alert would have been null.