-
Notifications
You must be signed in to change notification settings - Fork 314
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
Problems with tab_restart_browser #280
Comments
A try-catch clause does solve the problem for me.
This also resolves #279 . However, the code migth fail at the assert statment. But that did not happen in my minimalistic tests. |
Thanks! I bet this website is overwriting or wrapping I know we initially changed to this approach because of issues sending keyboard events to Firefox chrome after the upgrade to Selenium 3. I think it's worth revisiting those events to see if we're able to more reliably create and close windows. |
@englehardt can i work on this? |
@valkyr13 Yes. I suggest first trying what we used to do before upgrading to Selenium 3. I wonder whether some of the unreliability has since been fixed. |
@valkyr13 are you still on this? |
@vringar May I work on this? |
Go ahead! |
Once again, no worries! :) |
@vringar As outlined in this comment by Steven, I tried to check if key combinations would work.
Here's the code I was trying (using import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.webdriver import WebDriver
def main():
driver: WebDriver = webdriver.Firefox(executable_path='/Users/ankushdua/Downloads/geckodriver')
driver.get('http://www.mozilla.org')
action = ActionChains(driver)
action.key_down(Keys.COMMAND).send_keys('t').key_up(Keys.COMMAND).perform()
time.sleep(4)
driver.close()
if __name__ == '__main__':
main() What I understood:The shortcuts/key combinations that try to manipulate the tab or whole browser window do not seem to work at all (I could not get any of the combinations from 3 to 7 did not work at all). Please let me know what could be the next step. UpdateAs outlined in this StackOverflow answer, Selenium4 provides a new method to SwitchTo class: Here is the usage to that method(from new docs): # Opens a new tab and switches to new tab
driver.switch_to.new_window('tab')
# Opens a new window and switches to new window
driver.switch_to.new_window('window') Now, Selenium4 is still in the development stage and has not released the |
Thanks for the detailed writeup on this! |
I am looking into it. I will update you soon. |
@vringar I was looking into emulating keypresses using javascript but could not make it happen :( |
Then we'll just leave this open until selenium releases a version with |
I think we can wait this out and not introduce any more code on our side. Thanks for the suggestion though! |
Hi
I found another problem with the
tab_restart_browser
function. The problem seems to be that spawning a new window fails due to the same origin policy. Sadly the problem does not occur deterministically. But identified websites on which the problem sometimes occurs (1) https://jalopnik.com/tag/ford and (2) https://jalopnik.com/volkswagen-thieves-almost-pull-off-the-perfect-train-he-1833936849#repliesThis is the error I get
The text was updated successfully, but these errors were encountered: