assertion

How to verify a Text present in the loaded page through WebDriver

别说谁变了你拦得住时间么 提交于 2019-11-30 09:05:55
I need to verify a Text present in the page through WebDriver. I like to see the result as boolean (true or false). Can any one help on this by giving the WebDriver code? Ricardo Vila As zmorris points driver.getPageSource().contains("input"); is not the proper solution because it searches in all the html, not only the texts on it. I suggest to check this question: how can I check if some text exist or not in the page? and the recomended way explained by Slanec: String bodyText = driver.findElement(By.tagName("body")).getText(); Assert.assertTrue("Text not found!", bodyText.contains(text));

countNonZero function gives an assertion error in openCV

房东的猫 提交于 2019-11-30 07:14:41
问题 I tried to get horizontal projection using countNonZero() function as below. Mat src = imread(INPUT_FILE, CV_LOAD_IMAGE_COLOR); Mat binaryImage = src.clone(); cvtColor(src, src, CV_BGR2GRAY); Mat horizontal = Mat::zeros(1,binaryImage.cols, CV_8UC1); for (int i = 0; i<binaryImage.cols; i++) { Mat roi = binaryImage(Rect(0, 0, 1, binaryImage.rows)); horizontal.at<int>(0,i) = countNonZero(roi); cout << "Col no:" << i << " >>" << horizontal.at<int>(0, i); } But an error is occured in the line of

How to verify a Text present in the loaded page through WebDriver

戏子无情 提交于 2019-11-30 07:12:16
问题 I need to verify a Text present in the page through WebDriver. I like to see the result as boolean (true or false). Can any one help on this by giving the WebDriver code? 回答1: As zmorris points driver.getPageSource().contains("input"); is not the proper solution because it searches in all the html, not only the texts on it. I suggest to check this question: how can I check if some text exist or not in the page? and the recomended way explained by Slanec: String bodyText = driver.findElement

What is the expected syntax for checking exception messages in MiniTest's assert_raises/must_raise?

天涯浪子 提交于 2019-11-30 02:32:45
What is the expected syntax for checking exception messages in MiniTest's assert_raises / must_raise ? I'm trying to make an assertion something like the following, where "Foo" is the expected error message: proc { bar.do_it }.must_raise RuntimeError.new("Foo") You can use the assert_raises assertion, or the must_raise expectation. it "must raise" do assert_raises RuntimeError do bar.do_it end -> { bar.do_it }.must_raise RuntimeError lambda { bar.do_it }.must_raise RuntimeError proc { bar.do_it }.must_raise RuntimeError end If you need to test something on the error object, you can get it from

Best way to check that element is not present using Selenium WebDriver with java

℡╲_俬逩灬. 提交于 2019-11-30 01:03:54
Im trying the code below but it seems it does not work... Can someone show me the best way to do this? public void verifyThatCommentDeleted(final String text) throws Exception { new WebDriverWait(driver, 5).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver input) { try { input.findElement(By.xpath(String.format( Locators.CHECK_TEXT_IN_FIRST_STATUS_BOX, text))); return false; } catch (NoSuchElementException e) { return true; } } }); } eugene.polschikov i usually couple of methods (in pair) for verification whether element is present or not: public boolean

C++ assertion error while deleting object

∥☆過路亽.° 提交于 2019-11-29 17:39:28
I have strange assertion error and I can not find what is wrong with this code. Assertion expression is _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). I simplified code a bit for better readability. class Creator { public: virtual ~Creator() { for (MyObject* item : _list) { delete item; <-- assertion error here item = 0; } _list.clear(); } template <class T> T& create() { T * item = new T(); _list.push_back(item); return *item; } private: std::list<MyObject*> _list; }; class A : public MyObject, public Creator { }; class B : public MyObject, public Creator { }; int main() { A a; a.create<A>(); } <--

Selenium assertFalse fails with staleelementreferenceexception

走远了吗. 提交于 2019-11-29 16:31:07
I have a selenium test in Java and I am doing some assertions like that: assertFalse(isElementPresent(By.xpath("//td[2]/div"))); private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } It´s the standard method Selenium is generating when export from IDE to Java Webdriver. (Yes I want to assert that this element is not present) I always get errors when I am testing at this above code line Error: stale element reference: element is not attached to the DOM But when I put a thread.sleep in front of that step it works

Why do I get an assertion failure?

谁都会走 提交于 2019-11-29 15:34:55
This code fails when I try to debug it using VC2010: char frd[32]="word-list.txt"; FILE *rd=fopen(frd,"r"); if(rd==NULL) { std::cout<<"Coudn't open file\t"<<frd; exit(1); } char readLine[100]; while(fgets(readLine, 100, rd) != NULL) { readLine[strlen(readLine) - 1] = '\0'; char *token = NULL; token = strtok(readLine, " ,"); insert(readLine); } Debugging results in --------------------------- Microsoft Visual C++ Debug Library----------- Debug Assertion Failed! Program: ...\documents\visual studio 2010\Projects\bfa\Debug\bfa.exe File: f:\dd\vctools\crt_bld\self_x86\crt\src\fgets.c Line: 57

Debug Assertion Failed: _CrtIsValidHeapPointer(pUserData)

心不动则不痛 提交于 2019-11-29 14:43:39
Sometimes I get this "Debug Assertion Failed" error running my Qt project in debug mode ( image ). I don't know where I wrong because the compiler says nothing and I don't know what to do to find my error. I program under Windows Vista, using Qt Creator 2.4.1, Qt 4.8.1. My program has to read some informations from a laser device and save them into a file with a code similar to this: void runFunction() { configure_Scanning(...); while(...) { // do something scanFunction(); // do something } } and this is my "incriminated" function (where I think the problem is) void scanFunction() { file.open(

How to interpret c++ opencv Assertion error messages due to an error in cvtColor function?

只谈情不闲聊 提交于 2019-11-29 12:09:08
Following is an Assertion Error report (displayed on console) when calling cvtColor() function in opencv giving the argument CV_GRAY2BGR on a Mat object which is already a BGR image. I want to know how to interpret this error message by a person who yet doesn't know what the error here. (Hope some erudites won't vote to close this question as off topic, as I know there is a big value in learning to read Assertion or any other error messages for newbees for c++. ) And as I guess this might be most probably a opencv issue on reading assertion errors. OpenCV Error: Assertion failed (scn == 1 &&