Element could not be located on page. In selenium python winapp driver

46 views Asked by At

When I execute the code, I receive the message: "An element could not be located on the page using the given search parameters" and automation id is not showing in inspection tool so I am using name element here but name element not fetching.

My code


def test_initialize(self):

time.sleep(15)

string ="Create Project ... "

rawstring=r"{}".format(string)

self.driver.find_element(By.NAME, rawstring).click()


My error output from webdriver console

Host: 127.0.0.1:4723

User-Agent: appium/python 2.2.0 (selenium/4.1.0 (python windows))

{"using": "class name", "value": "Create Project \u2026"}

HTTP/1.1 404 Not Found

Content-Length: 139

Content-Type: application/json

{"status":7,"value":{"error":"no such element", "message": "An element could not be located on the page using the given search parameters."}

Why this error is coming could you help me.

1

There are 1 answers

4
CatBraaain On

Get element like <xxx>Create Project ... </xxx> with

driver.find_element(By.XPATH, "//*[contains(text(), 'Create Project ... ')]")

Get element like <div name = "Create Project ...">xxx</div> with

driver.find_element(By.NAME, rawstring)

Get element like <name>xxx</name> " with

driver.find_element(By.CSS_SELECTOR, "name")

Maybe you want first one ?