Ejemplo n.º 1
0
int wdFindElementByLinkText(WebDriver* driver, WebElement* element, const wchar_t* linkText, 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->selectElementByLink(elem, linkText, &wrapper);

		if (res != SUCCESS) {
			return res;
		}

		WebElement* toReturn = new WebElement();
		toReturn->element = wrapper;

		*result = toReturn;
		return SUCCESS;
	} END_TRY;
}
Ejemplo n.º 2
0
int wdFindElementByLinkText(WebDriver* driver, WebElement* element, const wchar_t* linkText, 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->selectElementByLink(elem, linkText);
	} catch (std::wstring& ) {
		return -1;
	}

	if (!wrapper) {
		return -2;
	}

	WebElement* toReturn = new WebElement();
	toReturn->element = wrapper;

	*result = toReturn;
	return 0;
}
Ejemplo n.º 3
0
int wdFindElementByLinkText(WebDriver* driver, WebElement* element, const wchar_t* linkText, WebElement** result)
{
	*result = NULL;
	if (!driver || !driver->ie) { return ENOSUCHDRIVER; }

	InternetExplorerDriver* ie = driver->ie;
	CComPtr<IHTMLElement> elem;
	if (element && element->element) {
		elem = element->element->getWrappedElement();
	}

	try {
		clock_t end = endAt(driver);
		int res = ENOSUCHELEMENT;

		do {
			ElementWrapper* wrapper;
			int res = ie->selectElementByLink(elem, linkText, &wrapper);

			if (res != SUCCESS) {
				continue;
			}

			WebElement* toReturn = new WebElement();
			toReturn->element = wrapper;

			*result = toReturn;
			return SUCCESS;
		} while (clock() < end);

		return res;
	} END_TRY;
}