False::False(std::shared_ptr<Element_> element, SourceLocation const& location) : Element(False_::Instance(), location) { if (0 == ElementHandle()) { throw BadCastException(); } }
False::False(Element_* element, SourceLocation const& location) : Element(dynamic_cast<False_*>(element), location) { if (0 == ElementHandle()) { throw BadCastException(); } }
Number::Number(std::shared_ptr<Element_> impl, SourceLocation const& location) : Element(impl, location) { SetFullyConstructed(true); if (0 == ElementHandle()) { throw BadCastException(); } }
Evaluate_ const* Evaluate::EvaluateHandle() const { return static_cast<Evaluate_ const*>(ElementHandle()); }
Evaluate_* Evaluate::EvaluateHandle() { return static_cast<Evaluate_*>(ElementHandle()); }
False_* False::FalseHandle() { return static_cast<False_*>(ElementHandle()); }
std::shared_ptr<Case_> Case::CaseHandle() const { return std::static_pointer_cast<Case_>(ElementHandle()); }
void FindElementCommandHandler::ExecuteInternal( const IECommandExecutor& executor, const ParametersMap& command_parameters, Response* response) { ParametersMap::const_iterator using_parameter_iterator = command_parameters.find("using"); ParametersMap::const_iterator value_parameter_iterator = command_parameters.find("value"); if (using_parameter_iterator == command_parameters.end()) { response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: using"); return; } if (!using_parameter_iterator->second.isString()) { response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "using parameter must be a string"); return; } if (value_parameter_iterator == command_parameters.end()) { response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: value"); return; } if (!value_parameter_iterator->second.isString()) { response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "value parameter must be a string"); return; } std::string mechanism = using_parameter_iterator->second.asString(); std::string value = value_parameter_iterator->second.asString(); if (mechanism != "css selector" && mechanism != "tag name" && mechanism != "link text" && mechanism != "partial link text" && mechanism != "xpath") { response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "using parameter value '" + mechanism + "' is not a valid value"); return; } BrowserHandle browser_wrapper; int status_code = executor.GetCurrentBrowser(&browser_wrapper); if (status_code != WD_SUCCESS) { response->SetErrorResponse(status_code, "Currently focused window has been closed."); return; } int timeout = static_cast<int>(executor.implicit_wait_timeout()); clock_t end = clock() + (timeout / 1000 * CLOCKS_PER_SEC); if (timeout > 0 && timeout < 1000) { end += 1 * CLOCKS_PER_SEC; } status_code = WD_SUCCESS; Json::Value found_element; do { status_code = executor.LocateElement(ElementHandle(), mechanism, value, &found_element); if (status_code == WD_SUCCESS) { response->SetSuccessResponse(found_element); return; } if (status_code == ENOSUCHWINDOW) { response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to find element on closed window"); return; } if (status_code != ENOSUCHELEMENT) { response->SetErrorResponse(status_code, found_element.asString()); return; } // Release the thread so that the browser doesn't starve. ::Sleep(FIND_ELEMENT_WAIT_TIME_IN_MILLISECONDS); } while (clock() < end); response->SetErrorResponse(ERROR_NO_SUCH_ELEMENT, "Unable to find element with " + mechanism + " == " + value); return; }
std::shared_ptr<Evaluate_ > Evaluate::EvaluateHandle() const { return std::static_pointer_cast<Evaluate_>(ElementHandle()); }
std::shared_ptr<Number_> Number::NumberHandle() { return std::static_pointer_cast<Number_>(ElementHandle()); }
std::shared_ptr<If_ > If::IfHandle() const { return std::static_pointer_cast<If_>(ElementHandle()); }
std::shared_ptr<Processing_> Processing::ProcessingHandle() { return std::static_pointer_cast<Processing_>(ElementHandle()); }
TailRecurse_ const* TailRecurse::TailRecurseHandle() const { return static_cast<TailRecurse_ const*>(ElementHandle()); }
TailRecurse_* TailRecurse::TailRecurseHandle() { return static_cast<TailRecurse_*>(ElementHandle()); }
SuperString_ const* SuperString::SuperStringHandle() const { return static_cast<SuperString_ const*>(ElementHandle()); }
std::shared_ptr<Funcall_ > Funcall::FuncallHandle() const { return std::static_pointer_cast<Funcall_>(ElementHandle()); }
SuperString_* SuperString::SuperStringHandle() { return static_cast<SuperString_*>(ElementHandle()); }
Nil_* Nil::NilHandle() { return static_cast<Nil_*>(ElementHandle()); }