0

I've gone through a number of similar topics here but they all seem to vary in how the pop-up window is designed. I've tried a few different ways and here is the most recent. So before I enter the login info, I need to click that client login button to access the login form but I can't even get it to open, let alone entering login information.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome('C:\Login Automation\chromedriver.exe')  
driver.get("https://www.datamyne.com/ ")

clientlogin = driver.find_element_by_xpath("//div[@id='holder']").click()
username = driver.find_element_by_xpath("//*[@id='user']").send_keys('myusername')
password = driver.find_element_by_xpath("//*[@id='pass']").send_keys('mypassword')

the error I'm getting here is "NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found"

the element of the first button is this:

<a style="position: relative" href="javascript:showHide('dialog-login');" class="green-btn user-login top-right-5">Client Login</a>

and then the actual login button is another javascript line:

<a href="javascript:loginDM();" style=" color: #fff; height: 40px; font-size: 29px; border-radius: 10px 0px 10px 10px;" class="green-btn bot-left-10"> Login</a>

Any tips as to how to approach this would be really appreciated!

1
  • Which line does that error occur on? Some of your code (I'm not sure if any of what's listed) must be trying to switch to a window handle which no longer exists. Is there any part of your code doing something like this? Commented May 25, 2021 at 14:35

3 Answers 3

1

I have inspect mention website login Form based on JavaScript. You can easily execute script through selenium. I have create a basic code snippet for you.

from selenium import webdriver
 
driver = webdriver.Chrome('chromedriver.exe')  
driver.get("https://www.datamyne.com/")

##Javascript script execute using selenium

clientlogin = driver.execute_script("javascript:showHide('dialog-login');")
driver.implicitly_wait(5)

username = driver.find_element_by_xpath('//*[@id="User"]').send_keys('myusername')
password = driver.find_element_by_xpath('//*[@id="Pass"]').send_keys('mypassword')
save =  driver.find_element_by_xpath('//*[@id="formLoginDM"]/div[1]/a').click()

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

2 Comments

that worked! really appreciate it. Now the website has blocked me for trying to do that haha are they able to tell that it's a bot trying to connect and not a person?
I have scraped many websites but not find that kind of issue in selenium. if are facing blockage issue that you can change header / webdriver(geckodriver). if issue still persist then you try proxy-pool . I have implement on scrapy not in selenium.
0
clientlogin = driver.find_element_by_xpath("//div[@id='holder']").click()

The xpath is off. The holder isn't what you need to click.

I suspect you want:

clientlogin = driver.find_element_by_xpath("//a[text()='Client Login']").click()

2 Comments

I've just tried that and got something new to me: ElementClickInterceptedException: Message: element click intercepted: Element <a style="position: relative" href="javascript:showHide('dialog-login');" class="green-btn user-login top-right-5">...</a> is not clickable at point (793, 85). Other element would receive the click: <div class="cli-bar-container cli-style-v2" style="padding-top: 10px">...</div>
when? sounds like there is a pop up covering the elements you want.
0

Can you try this xpath once for the 'Client Login' pop-up modal

clientlogin = driver.find_element_by_xpath("//a[@class='green-btn user-login top-right-5']']").click()

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.