int wdFindElementByName(WebDriver* driver, WebElement* element, const wchar_t* name, WebElement** result) { CComPtr<IHTMLDOMNode> res; InternetExplorerDriver* ie = driver->ie; CComPtr<IHTMLElement> elem; if (element && element->element) { elem = element->element->getWrappedElement(); } ElementWrapper* wrapper = NULL; try { wrapper = ie->selectElementByName(elem, name); } catch (std::wstring& ) { return -1; } if (!wrapper) { return -2; } WebElement* toReturn = new WebElement(); toReturn->element = wrapper; *result = toReturn; return 0; }
int wdFindElementByName(WebDriver* driver, WebElement* element, const wchar_t* name, WebElement** result) { if (!driver || !driver->ie) { return ENOSUCHDRIVER; } CComPtr<IHTMLDOMNode> res; InternetExplorerDriver* ie = driver->ie; CComPtr<IHTMLElement> elem; if (element && element->element) { elem = element->element->getWrappedElement(); } try { ElementWrapper* wrapper; int res = ie->selectElementByName(elem, name, &wrapper); if (res != SUCCESS) { return res; } WebElement* toReturn = new WebElement(); toReturn->element = wrapper; *result = toReturn; return SUCCESS; } END_TRY; }