I tried to use webdriver to login to two websites, A and B. But when I use the same way "find_element_by_css_selector", B was not working while A was working. I turned the javascript off, and find B's login section disappeared.
A's html:
<button type="submit" class="width-35 pull-right btn btn-sm btn-primary">
<i class="ace-icon fa fa-key"></i>
<span class="bigger-110">Login</span>
</button>
Code of A is working well:
submit=driver.find_element_by_css_selector(".width-35.pull-right.btn.btn-sm.btn-primary").click()
B's html:
<a class="login-btn" href="javascript:;" data-bind="click: loginSection.loginClick">
<span class="btn-text">Login</span>
</a>
Code of B is not working:
submit=driver.find_element_by_css_selector("a.login-btn > span.btn-text").click()
Error says:
ElementNotVisibleException: Message: element not visible
I posted another question before, Python: find_element_by_css_selector, and someone suggested me to use "find_elements_by_link_text" and it works, but it only works with that one. I would still like to know how to solve this problem. Thanks!
Updated:
Link=WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='login-btn'][@class='login-btn']"))).click()
Error:
TimeoutException: Message: