0

enter image description here

In the above HTML, I would like to get the Value "INC3000...". But if I use get_attribute() the value returned is None as it is rendered in JavaScript during runtime.

How can I get the value of "href=javascript:" (INC30000004609 (New))?

1
  • Update the question with a bit more of the outerHTML so the element with text as INC30000004609 can be uniquely identified. Commented Aug 3, 2018 at 9:36

1 Answer 1

1

You need to use explicit wait for the result ready. JS rendered element cannot be obtained without waiting. Neither simple requests, nor selenium without waiting.

wait = WebDriverWait(driver, 10)
element = wait.until(element_has_text(By.XPATH, '//a[contains(@class, "btn")]'))    
class element_has_text(object):

    def __init__(self, locator, css_class):
        self.locator = locator

    def __call__(self, driver):
        element = driver.find_element(*self.locator)   # Finding the referenced element
        if element.text:
            return element
        else:
            return False   
Sign up to request clarification or add additional context in comments.

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.