Searching for the perfect way to choose 'mat-checkbox' using the selenium webdriver?

There are 4 checkboxes that I need to select using Angular code and Selenium for automation.

Please refer to the provided code for assistance.

I specifically need to select the checkbox labeled "Main st & 19th St".

View image description here

Answer №1

Feel free to experiment with this code snippet.

driver.findElement(By.xpath("//*[@class='mat-checkbox-label'][text()='Main st & 19th St']")).click();

Alternatively, you can also use

driver.findElement(By.xpath("//*[@id='mat-checkbox-1']/label")).click();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Python Selenium: Variable encoding gets altered by XPath

I am facing an issue with my code that uses XPath to search through text. The problem arises when the text being searched contains special Latin characters like ñ or í. After encoding the text, it displays correctly when printed. However, the issue occu ...

Can you guide me to where I can locate the list of arguments for Chrome and Internet Explorer?

Is there a way to access the list of arguments for Chrome and Internet Explorer similar to how we use 'about:config' in Mozilla for preferences? EDIT -I For example, options.addArguments("disable-popup-blocking", "true"); options.addArguments(" ...

"Altair_Saver halts mid-loop due to a WebDriverException: Error Message: An unknown error occurred - the result of the function call must

The solution presented in response to this particular query appeared to be effective. However, after running the loop for 3 iterations, an unexpected issue occurred. The error message that was displayed is proving to be quite challenging to interpret. - ...

The @JsonIgnore annotation is failing to function as expected

It seems like the @JsonIgnore annotation is not functioning as expected in my project. I have come across some suggestions stating that this issue may arise due to the use of incompatible Jackson versions (org.codehaus vs. com.fasterxml). However, I am onl ...

Although Actions allow for selecting elements, they do not support dragging elements to a specific location, as the drop functionality is triggered on hover

Link to the URL - System.setProperty("webdriver.chrome.driver", "D:\\Eclipse\\Files\\chromedriver_win32\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().fullscreen(); ...

Searching for elements in Selenium using JavaScript's equivalent of findElement(by.className)

I need to locate an id tag within a class tag on an html page. driver.find_element(By.XPATH, "//div[@class='Content warning']/p").get_attribute("id") https://i.stack.imgur.com/NlU8t.png I successfully accomplished this with ...

Using Selenium to determine the quantity of elements that have a similar class present

Here is the test code I am using: it('count elements by class', async t => { let count = await driver.findElements(By.css('my-questions-class')).then(v => v.length); assert.equal(count, 3); // The count should b ...

I am receiving an error message that says 'selenium module not found'

I have been attempting to install the selenium package multiple times. I have entered the following commands: python3 -m pip install selenium pip3 install selenium pip install selenium and so on. Despite seeing it installed in the output of pip list, I ...

Step-by-step guide on dynamically adding "Input Tags" to the DOM at runtime using Selenium's JavascriptExecutor

In order to dynamically add the following element to the DOM during run time, I need assistance... <input type="text" name="imagesToAdd" value="3566"> My initial attempt was to use Selenium JavascriptExecutor for this task. However, I encounter ...

Retrieve the content from the text node located directly above the span tag

Here is a snippet of the HTML content I'm looking to extract using Python and Selenium: <h2 class ="page-title"> Strange Video Titles <span class="duration">28 min</span> <span class="video ...

Updating Appium on Ubuntu operating system

After successfully installing Appium on my Ubuntu machine using npm install -g appium I now find the need to upgrade it to a newer version, such as 0.18.2 or a version lower than Appium 1.0.0. npm update -g appium The problem is that when I try this ...

Discovering the element based on its label

I have a div labeled "First Name" that I need to locate in my Selenium end-to-end test: <div class="control-group ng-class: { 'error': isInErrorState() } ng-scope" dto-control-group="" label="First Name"> <label class="control-label ...

The ElementClickInterceptedException error is occurring because the select element is being obscured by another element, specifically an iframe with the id "ba-widget-iframe"

I am dealing with a drop down single select combo box and I am able to access it using a CSS selector. <select class="single-option-selector no-select selector single-option-selector-100" data-option="option1" id="product-select ...

WebDriver is not recognized as a type and ChromeDriver cannot be resolved as a type

Despite using the latest versions listed below, I am still encountering the issue mentioned above. Can anyone provide assistance? Eclipse IDE Version: 2019-12 (4.14.0); WebDriver (Java) - 3.141.59 ChromeDriver 79.0.3945.36 Below is the code snippet: pa ...

Does AngularJS have a feature similar to jQuery.active?

As I utilize selenium to conduct tests on my application, I am encountering numerous ajax calls that utilize $resource or $http. It would be convenient if there was a method in angular to monitor active ajax requests so that selenium could wait until they ...

Having difficulty starting Chrome on Mac OSX with Selenium grid

Attempting to conduct automation testing with Selenium & Java on MAC Sierra, encountering an error while running the testng.xml: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{browserName=chrome, ch ...

WebDriver Sampler: ThreadStarted Error - The process is still ongoing, hence no results are accessible as of yet

WDS.sampleResult.sampleStart() var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait) var wait = new support_ui.WebDriverWait(WDS.browser, 15000) WDS.browser.get('http://jmeter-plugins.org') var support_ui = JavaImporter(or ...

Utilizing JSON data to create interdependent Android spinners

After spending countless hours going through code, I am still unable to figure out what I'm doing wrong. The frustration is real... In the process of developing an Android app, I need to implement two spinners within a single activity. The second spi ...

Dealing with the "Accept all cookies" popup for the data-testid element in Python with Selenium

I've recently taken on a new project to assist a medium-sized business with their solar panel operations. My goal is to extract data from a specific website using Selenium in Python, and display it on a GUI that a friend of mine is working on. However ...

Having trouble transitioning to a web element?

It seems that selenium is not interacting with a webelement until it's in view, causing issues when trying to scroll and click on a specific button. Instead of scrolling the element into view, it randomly scrolls to a different location on the page. ...