Selenium locate element fails when Chrome in background
You should use either one of the below locators before jumping to XPath.
- ID
- name
- classname
- linkText
- partialLinkText
- tagName
- css selector
- xpath
Also, make sure that you should not be using absolute xpath
, rather it should be relative xpath
.
So, Instead of these
loginuser = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="layers"]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div[5]/label/div/div[2]/div/input')))
loginuser.send_keys("Username")
sleep(5)
loginuser.send_keys(Keys.RETURN)
loginuser = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="layers"]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div[3]/div/label/div/div[2]/div[1]/input')))
loginuser.send_keys("Password")
sleep(5)
loginuser.send_keys(Keys.RETURN)
Use this:
wait = WebDriverWait(driver, 30)
loginuser = wait.until(EC.visibility_of_element_located((By.NAME, "text")))
loginuser.send_keys("Username", Keys.RETURN)
loginPassword = wait.until(EC.visibility_of_element_located((By.NAME, "password")))
loginPassword.send_keys("password here", Keys.RETURN)
after navigate() method web page is stopped working in selenium
It gets to load properly by Javascript, Jquery, and Angular. Until page get not loaded fully, it will be under downstage and can't iterate to next line of code.
The selenium webdriver test is stopped after a random number of iterations clicks
Finally I rewrite my test to C#. To my knowledge Java doesn't support click timeout. Similar code in C# doesn't freeze my program but after 60 seconds throws an exception (what is desirable in my case). What is more the same program in Java works proper on Windows 10 with a little higher version of IE (before I worked on Windows 8). I don't know why it happens, but maybe it could be clue for someone in the future.
Related Topics
C# - Set Directory Permissions for All Users in Windows 7
Gmail Smtp via C# .Net Errors on All Ports
Popup's in Selenium Webdrivers
Using Datetime in a SQLparameter for Stored Procedure, Format Error
Return/Consume Dynamic Anonymous Type Across Assembly Boundaries
The Type Arguments for Method Cannot Be Inferred from the Usage
Convert Datetime to Date Format Dd/Mm/Yyyy
Split String into String Array of Single Characters
What Is Passing Parameters to SQL and Why Do I Need It
Filter All Queries (Trying to Achieve Soft Delete)
Can a Static Method Be Overridden in C#
How to List Directory Contents with Ftp in C#
Changing Project Port Number in Visual Studio 2013
What Does Maxdegreeofparallelism Do