New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alert = driver().switch_to.alert alert.accept() throws NoAlertPresentException #128
Comments
@byakatat are you sure that alert apears? Selene don't wait for alert to appear |
@SergeyPirogov I'm absolutely sure. |
And this is simple web application? Not Angular or something else? |
@SergeyPirogov yes, it's simple web app. Here is a screenshot of alert https://yadi.sk/i/qi-MXW3V3HTHQg |
will look into it... |
Hm... We have tests for alerts: https://github.com/yashaka/selene/blob/master/tests/integration/test_alert.py And they pass... That means that something may be wrong with your alert, @byakatat :) Can you share link to production site? So we can look more closely what kind of alert do you have? |
@yashaka
And as I mentioned, when I use standard driver tests pass. |
Thanks, I will try to find the reason...
…On Tue, May 16, 2017, 3:11 AM byakatat ***@***.***> wrote:
@yashaka <https://github.com/yashaka>
Sure. Use Chrome browser.
1. Login here login page <https://m.florist.ru/users/login/>
with email: ***@***.*** and password: 123456
2. Click on the logo on the left top corner - a main page will be
opened
3. Click on any bouquet - a bouquet page will be opened
4. Click "Оформить заказ" button - a cart page will be opened
5. Click "Оформить заказ" button again - a delivery date page will be
opened
6. Click "Следующий шаг" button - a recipient page will be opened
7. And here you should choose recipient from dropdown, look here
https://yadi.sk/i/pAdyELYD3JC9Sm
and allert will appear.
And as I mentioned, when I use standard driver tests pass.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB3snhCFkGuN6qKx-Aj0wuHuQW5ERQBUks5r6T4MgaJpZM4NJ0f5>
.
|
CheckI have checked the situation in actual 2.0.34a selene core api version. And there is no problem. I resurrected alert tests for 2.0.34a core api: 8b53e71 and ensured that they work fine. import os
import pytest
from selenium import webdriver
from selenium.common.exceptions import NoAlertPresentException
from webdriver_manager.chrome import ChromeDriverManager
from selene import Config, Browser
start_page = 'file://' + os.path.abspath(os.path.dirname(__file__)) + '/../resources/start_page.html'
@pytest.fixture(scope='session')
def session_driver():
chrome_driver = webdriver.Chrome(ChromeDriverManager().install())
yield chrome_driver
chrome_driver.quit()
@pytest.fixture(scope='function')
def session_browser(session_driver):
yield Browser(Config(driver=session_driver))
def test_can_accept_alert(session_browser):
session_browser.open(start_page)
session_browser.element("#alert_btn").click()
session_browser.driver.switch_to.alert.accept()
try:
session_browser.driver.switch_to.alert
assert False, 'actual: alert presents, expected: alert not present'
except NoAlertPresentException:
assert True
def test_can_dismiss_confirm_dialog(session_browser):
session_browser.open(start_page)
session_browser.element("#alert_btn").click()
session_browser.driver.switch_to.alert.dismiss()
try:
session_browser.driver.switch_to.alert
assert False, 'actual: alert presents, expected: alert not present'
except NoAlertPresentException:
assert True
def test_alert_is_present(session_browser):
session_browser.open(start_page)
session_browser.element("#alert_btn").click()
try:
session_browser.driver.switch_to.alert
assert True
except NoAlertPresentException:
assert False, 'actual: alert not present, expected: alert is present' SuggestionThe problem of TC could be in selene version 1.0.10a because it hadn't clear and consistent api yet. There is no code to check he used selene api properly. I upped tests of selene version 1.0.10a too, and had the trouble with the api, cause from selene.browser import driver, visit
visit(page)
driver().switch_to.alert.accept()
So the script of calling alert in selene 1.0.10a should look like in tests below: import os
from time import sleep
from selenium.common.exceptions import NoAlertPresentException
from selene import factory, browser
start_page = 'file://' + os.path.abspath(os.path.dirname(__file__)) + '/../resources/start_page.html'
# todo: ensure works and enabled
def test_can_accept_alert():
browser.visit(start_page)
browser.element("#alert_btn").click()
shared_driver = factory.get_shared_driver()
shared_driver.switch_to.alert.accept()
try:
shared_driver.switch_to.alert.accept()
assert False, 'actual: alert presents, expected: alert not present'
except NoAlertPresentException:
assert True
def test_can_dismiss_confirm_dialog():
browser.visit(start_page)
browser.element("#alert_btn").click()
shared_driver = factory.get_shared_driver()
shared_driver.switch_to.alert.dismiss()
try:
shared_driver.switch_to.alert.dismiss()
assert False, 'actual: alert presents, expected: alert not present'
except NoAlertPresentException:
assert True ResolutionIssue not reproduced. The problem could be in not proper usage of the selene - check the "Suggestion" block above. Issue can be closed until we see the whole code with imports which TC has used to reproduce the issue. |
@byakatat does this problem still actual on
|
So, after all discussions... This seems to be not a bug. Yet, the discussion revealed the topic of "waiting for alert". I have created a separate issue for that: #248 |
When i use selene and try to accept alert:
I get this error:
......\MobilePages\RecipientPageM.py:23: in choose_recipient_from_list
alert.accept()
..........\selene-virt\lib\site-packages\selenium\webdriver\common\alert.py:80: in accept
self.driver.execute(Command.ACCEPT_ALERT)
..........\selene-virt\lib\site-packages\selenium\webdriver\remote\webdriver.py:233: in execute
self.error_handler.check_response(response)
E selenium.common.exceptions.NoAlertPresentException: Message: no alert open
E (Session info: chrome=58.0.3029.81)
E (Driver info: chromedriver=2.29.461591
While when i use standart driver it works fine:
The text was updated successfully, but these errors were encountered: