Development

I have Jquery calender in my application. I have task to select dates from different months using Selenium, but I can do only previous month and forward month. Actually I need to select dates from random months by specifying the date and month as input. If there is a way to achieve it let me know.

**My code for Selecting Previous Month date.**

public static void Date_Picker(String datetoselect,String Xpath,String month) {
// Click on the Given Calender Button
driver.findElement(By.xpath(Xpath)).click();

driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/a[1]”)).click();

WebElement Month = driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/div[@class=’ui-datepicker-title’]/span”));
String Month_Message = Month.getText();

if(Month_Message.contains(month))
{
WebElement dateWidget = driver.findElement(By.className(“ui-datepicker-calendar”));

List<WebElement> rows=dateWidget.findElements(By.tagName(“tr”));

List<WebElement> columns=dateWidget.findElements(By.tagName(“td”));

for (WebElement cell: columns){

if (cell.getText().equals(datetoselect)){

cell.findElement(By.linkText(datetoselect)).click();
break;

}
}
}

We are trying to get our automated webtests working independently of what version of Chrome we’re using. These automated tests work as follows:

We have a Karaf container agent running as a service;
Karaf starts an ant script, which in turn starts another ant script. The first ant script is part of the automation tool we use (our own product) and the second ant script is the actual script that starts our testng webtests;
TestNg, during the startup, starts the ChromeDriver in the following way using the bonigarcia Webdrivermanager library:

WebDriverManager.chromedriver().setup();
// webDriver = new ChromeDriver();
ChromeOptions options = new ChromeOptions();

// ChromeDriver is just AWFUL because every version or two it breaks unless you pass cryptic arguments
//AGRESSIVE: options.setPageLoadStrategy(PageLoadStrategy.NONE); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html
options.addArguments(“–enable-automation”); // https://stackoverflow.com/a/43840128/1689770
options.addArguments(“–headless”); // only if you are ACTUALLY running headless
options.addArguments(“–no-sandbox”); //https://stackoverflow.com/a/50725918/1689770
options.addArguments(“–disable-infobars”); //https://stackoverflow.com/a/43840128/1689770
options.addArguments(“–disable-dev-shm-usage”); //https://stackoverflow.com/a/50725918/1689770
options.addArguments(“–disable-gpu”); //https://stackoverflow.com/questions/51959986/how-to-solve-selenium-chromedriver-timed-out-receiving-message-from-renderer-exc
options.addArguments(“–window-size=1920,1080”);
options.addArguments(“–start-maximized”);
options.addArguments(“–disable-extensions”);
options.setExperimentalOption(“useAutomationExtension”, false);
options.addArguments(“–bwsi”);
options.addArguments(“–user-data-dir=”+ System.getProperty(“test.web.chrome.data.dir”) +”/user-data-dir”);
options.addArguments(“–disk-cache-dir=”+ System.getProperty(“test.web.chrome.data.dir”) +”/disk-cache-dir”);
try {
File logFile = new File(System.getProperty(“test.web.chrome.data.dir”).replace(“/”, “\”) + “\logs\chromedriver.log”);
logFile.getParentFile().mkdirs();
logFile.createNewFile();
boolean verbose = System.getProperty(“test.web.webdriver.verbose”).equals(“true”);
ChromeDriverService driverService = new Builder().withVerbose(verbose).withLogFile(logFile).build();

webDriver = new ChromeDriver(driverService, options);
} catch (IOException e) {
LOGGER.error(e);
webDriver = new ChromeDriver(options);
}

The problem we have is that if the Karaf agent is running as the LOCAL_SYSTEM account (which is the default user when creating a new service), the Chromedriver can’t start Chrome with the error:

unknown error: cannot create temp dir for unpacking extensions

After some googling and testing, I’ve found this is because when starting the ChromeDriver, it tries to create a temporary folder for unpacking extensions in the user temp directory, which fails because the LOCAL_SYSTEM account doesn’t have a user directory.

I can work around the issue by making the service run as a LOCAL_SERVICE account, which does have a user directory, but we’ve found that some other scripts that run on this Karaf agent give problems when running as LOCAL_SERVICE (mainly older software integrations that we can’t easily upgrade), so ideally I’m hoping for a solution that makes LOCAL_SYSTEM work.

Is there a way to fix the temp dir problem that the Chromedriver has when attempting to start Chrome from a LOCAL_SYSTEM service?

In my college, I learned about Integration testing in which we combine the whole code together and then test it at once after we are done with unit testing.

A few days back, I heard about Jenkins, which says it does Continuous Integration Testing. I read about it and learned that it means that a developer pushes his/her code several times a day to Jenkins for testing instead of sending the code at the end of the day.

I was confused so I went to read about it from Wikipedia but it didn’t help. I read the two links below

Integration testing

Continuous integration

ELI5

What does this all mean?

What is the difference between Regular Integration Testing and Continuous Integration Testing?

How do I find the element with text “Jessica” based on “3000” displaying in the web page using xpath?
I’m getting …not a valid xpath error.
<div>
<span><b>Jessica</b></span>
<br>
<label>Total Wealth ($):</label>
<p>3000</p>
</div>

I tried this
RichestPersonName = browser.find_element_by_xpath(“//p[text()=’3000′] .. /span”).text

but it shows
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //p[text()=’3000′] .. /span because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//p[text()=’3000′] .. /span’ is not a valid XPath expression.

Discover some of the interesting features that have landed in stable and beta web browsers during June 2024. Source: web.dev:…