[Solved] How to count total number of products on webpage and verify if those are correct with Selenium webdriver in Java? [closed]

The below java code will help you do the task Here we create a driver instance go to the website url take all the products into a list and compare it with the text “1-15 of 38 Matching Products” public static void main(String[] args) { WebDriver driver=new FirefoxDriver(); driver.get(“http://www.samsung.com/us/video/home-audio/all-products”); List products = driver.findElements(By.className(“product-image”)); String pagination_no[]=driver.findElement(By.xpath(“//*[@id=’category_filter’]/section/div[1]/div/div[1]/h1″)).getText().split(” … Read more

[Solved] How can I check if date is before a specific time?

So I got following code that works for me: public void setOverdueFlagIfRequired(Date today, Date causedAtDate) { Calendar now = Calendar.getInstance(); now.setTime(today); Calendar causedAt = Calendar.getInstance(); causedAt.setTime(causedAtDate); Calendar yesterday2300 = Calendar.getInstance(); yesterday2300.setTime(today); yesterday2300.add(Calendar.DATE, -1); yesterday2300.set(Calendar.HOUR_OF_DAY, 23); yesterday2300.set(Calendar.MINUTE, 0); yesterday2300.set(Calendar.SECOND, 0); yesterday2300.set(Calendar.MILLISECOND, 0); Calendar fiveDaysBack2300 = Calendar.getInstance(); fiveDaysBack2300.setTime(yesterday2300.getTime()); fiveDaysBack2300.add(Calendar.DATE, -4); if (causedAt.compareTo(fiveDaysBack2300)<=0) { setFiveDaysOverdue(true); } else if … Read more

[Solved] C# – float[][] declaration

Well, there are two different types: Array of array (jagged array): float[][] sample = new float[][] { new float[] {1, 2, 3}, new float[] {4, 5}, // notice that lines are not necessary of the same length }; 2d array: float[,] sample2 = new float[,] { {1, 2, 3}, {4, 5, 6}, }; Edit: your … Read more

[Solved] Incomparable types: String and class name

I’m guessing the error is thrown at this line if(cari == buku1.Perpus[1]) Since you’re comparing a String to a Perpus object in your array here. You need to add some getter methods to your class, so that you can compare Strings in your array elements to the String cari. Eg: class perpus { private String … Read more

[Solved] how to create a string like regex

You can simple use ToString with parameter: private string getResult(int x) { return x.ToString(“0000”); } from @Dmitry Bychenko : You can also use “D4” as parameter instead of “0000” with same results. This solution also works with negative numbers instead of PadLeft method. 1 solved how to create a string like regex

[Solved] How to parse a file matching all the lines for a string and keep track of count?

Open the file and read all lines with open(“file.txt”) as f: lines = f.read().splitlines() Make a list of lines that contain the word “Error” data = [ line.lstrip(‘<‘).rstrip(‘>’).split(‘><‘) for line in lines if ‘Error’ in line ] Get the time and message items from the data list errors = [ { ‘time’ : line[0], ‘message’: … Read more

[Solved] How to form a dynamic array in C++?

Use std::vector, which is designed for exactly this use case. The (rough) translation of the Perl code you have given to C++ using std::vector would be something like this: #include <iostream> #include <vector> int main() { // Declare a vector that can only contain int values. std::vector<int> numbers; // Put the numbers [1,10] into the … Read more

[Solved] Why can’t I get the index of a jQuery object?

I don’t think map() is giving you want you want. Since you want to filter element from an array it’s easier to use filter() instead of map(). function $errorObjectFunction() { return $(“div[id^=name]”).filter(function() { return ($(this).find(“:first-child”).hasClass(“error”) == true || $(this).find(“.field_error”).length > 0) }); } var $self = $(“#self”); var jdks = $errorObjectFunction(); var hdjs = $self.parent().parent().parent(); … Read more

[Solved] When will objects allocated on a thread be freed after the thread completes? [closed]

The simple answer is eventually: no sooner, no later. You have no direct control over when garbage will be collected. Provided the instance has no more references to it, the garbage collector will clean it up at some point. 4 solved When will objects allocated on a thread be freed after the thread completes? [closed]

[Solved] how to copy 1-D array to 2-D array

You need a char for the final \0, I have used a loop to get the 2 char #include <string.h> #include <stdio.h> int main(void) { static char pvtsWsMthDayTab[25]=”312831303130313130313031″; char sDaysInMth[12][3] ; memset(sDaysInMth, 0, sizeof(sDaysInMth)); for(int i = 0; i < 12; i++) { for (int j = 0; j < 2; j++ ) { sDaysInMth[i][j] … Read more