Reputation: 15
I am trying to automate the start of day procedures using selenium, I am trying to select and click a "tag" button, but no matter what way I do it there is a no element error.
I have tried XPath, css selector, class name, tag name, id, checking for iframe, checking if element is loaded. I just cant seem to get it.
This is the HTML of the website
<div class="contact-list-menu-tags">
<div class="search-item popover-content-item tag with-tooltip ">
-------> <span class="search-item-text popover-content-item-text">call</span> <-----
<div class="tooltip __pos-center __pos-top">
<div class="tooltip-content">
<div class="ico-hover ico-s">
<div class="ico ico-pencil ico-s __alt4 __not-hovered"></div>
<div class="ico ico-pencil ico-s __gray __hovered"></div></div>
<div class="ico-hover ico-s"><div class="ico ico-trash ico-s __alt4 __not-hovered"></div>
<div class="ico ico-trash ico-s __alt1 __hovered"></div></div></div></div></div>
<div class="search-item popover-content-item tag with-tooltip "><span class="search-item-text popover-content-item-text">CEO</span><div class="tooltip __pos-center __pos-top">
<div class="tooltip-content">
<div class="ico-hover ico-s">
<div class="ico ico-pencil ico-s __alt4 __not-hovered"></div>
<div class="ico ico-pencil ico-s __gray __hovered"></div></div>
<div class="ico-hover ico-s"><div class="ico ico-trash ico-s __alt4 __not-hovered"></div>
<div class="ico ico-trash ico-s __alt1 __hovered"></div></div></div></div></div></div>
Sorry its a bit of a mess but Im not sure how to fix the formatting after copying it, the element i am trying to locate and click is the 3rd line from the top with the arrows
Here is the current code i am working on
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://www.nimble.com/') #goes to address
#login process
loginbutton = driver.find_element_by_xpath('/html/body/nav/div[1]/ul/li[8]/a')
loginbutton.click()
time.sleep(2)
username = driver.find_element_by_xpath('/html/body/form/div/div[1]/div/div[2]/input')
username.send_keys('[email protected]')
time.sleep(1)
psswrd = driver.find_element_by_xpath('/html/body/form/div/div[1]/div/div[3]/input')
psswrd.send_keys('Password112')
signin = driver.find_element_by_xpath('/html/body/form/div/div[1]/div/button')
signin.click()
time.sleep(2)
#go to contacts
driver.get('https://app.nimble.com/#app/contacts/list')
time.sleep(4)
#search tag
calltag = driver.find_element_by_css_selector('span.content')
calltag.click()
driver.find
#//*[@id="app"]/div/div[1]/div/div[1]/div[2]/div[6]/div[1]/span
#document.querySelector("#app > div > div.contact-list-menu > div > div:nth-child(1) > div.contact-list-menu-inner > div.contact-list-menu-tags > div:nth-child(1) > span")
#app > div > div.contact-list-menu > div > div:nth-child(1) > div.contact-list-menu-inner > div.contact-list-menu-tags > div:nth-child(1) > span
#<span class="search-item-text popover-content-item-text">call</span>
#/html/body/div[1]/div[1]/div/div[1]/div/div[1]/div[2]/div[6]/div[1]/span
#document.querySelector("#app > div > div.contact-list-menu > div > div:nth-child(1) > div.contact-list-menu-inner > div.contact-list-menu-tags > div:nth-child(1) > span")
The commented out stuff at the bottom is all the things i have/am trying. The username and password that are in there is just a tester account, so feel free to use it to test anything.
Thanks!
Upvotes: 1
Views: 439
Reputation: 7563
Your element target inside a <iframe>
tag, you need switch it first.
Please use .frame_to_be_available_and_switch_to_it
method to handle. And for your element, you can use this xpath //span[text()="call"]
#go to contacts
driver.get('https://app.nimble.com/#app/contacts/list')
wait = WebDriverWait(driver, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'reactContactListFrame')))
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//span[text()="call"]')))
element.click()
Upvotes: 1