1

I am using Selenium-python script for web test automation. When ever I use selenium inbuilt commands, I will get Attribute error during run time.

Ex: selenium.WindowFocus("preview_email") throws "AttributeError: class selenium has no attribute 'WindowFocus'"

I am new to test automation. Help me to sort out this problem.

3 Answers 3

4

The command that you are looking for is selenium.window_focus()

Sign up to request clarification or add additional context in comments.

Comments

0

I have never used the Python client personally, but a quick glance at the selenium.py file reveals that there is a window_focus command which gives the currently "selected" window focus ("selected" in Selenium terms is the window that Selenium is currently executing commands against and not necessarially the window that has user focus).

Executing the select_window command with a window ID will set tell Selenium which window you want to execute commands against.

I have had some trouble w/ popups in general and the way the Selenium IDE and RC clients attempt to locate new windows and/or there parents. Good luck.

Comments

0

I think you want to force web-driver to go to another window with name "preview_email".

For this purpose, you need to use selenium.switch_to_window("preview_email"); because selenium.window_focus() just gives focus to the currently selected window and accepts no arguments. Additionally you used it in JAVA mode (I mean selenium.windowFocus()).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.