Find Element Using Attribute and Tag Name in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:02:02

1K+ Views

We can find an element using the element tag name with Selenium webdriver with the help of locator tagname. To locate an element with tagname, we have to use the By.tagName method.In the html code, a tagname is usually enclosed by , for example, an anchor tag represents links on the page. An input tag represents text boxes, checkboxes or radio buttons. Let us look at the html code of an element and try to identify it with its tagname −In the above image, the text – You are browsing the best resources for has the h4 tag.SyntaxWebElement e ... Read More

ChromeDriver Executable Does Not Exist - IllegalStateException in Java Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:01:42

4K+ Views

An IllegalStateException is thrown while working with Chrome browser if the chromedriver.exe file path is set incorrectly in the method System.setProperty. Once this executable file is downloaded, it has to be extracted. Then its path should be copied and added as a parameter to the System.setProperty method.SyntaxSystem.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\DebomitaJava\chromedriver.exe")Also, it must be remembered that, for Windows, we have to specify the .exe extension while including the path. But it is not required for Mac or Ubuntu. We should also ensure that the chromedriver.exe file that we are using is compatible with the local Chrome browser version.Let us see an example for ... Read More

Find Elements Using Selenium WebDriver

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:01:10

564 Views

We can find elements using Selenium webdriver with the help of the findElements method. This can be applied to the locators like id, class, name, link text, partial link text, css, xpath and tagname.The findElements method returns a list of elements which match with the locator (with the By object) passed as a parameter to the method. To count the number of elements returned by the list, the method size is used. If there are no matching elements, an empty list is returned.The below image shows the list of methods available with findElements.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; ... Read More

Convert JSON to CSV File Using PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 08:00:52

4K+ Views

To convert the JSON to the CSV format we need to first use the ConvertFrom-JSON command. For example, we have already JSON file present with us at the C:\temp\VMinfo.JSON location. We will first import this file and then convert it to CSV as shown below.Get-Content C:\Temp\VMInfo.json | ConvertFrom-Json | Export-Csv C:\Temp\vminfo.csv -NoTypeInformationSuppose you have cmdlet that produces output in the hash table format as shown below.PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags Key             Value ---             ----- For             Ansible Patching_Day ... Read More

Change Azure Tag Value Using PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 07:59:15

1K+ Views

To change the azure value using PowerShell we need to use the Update-AZTag command with the merge property.ExampleFor example, we have the Azure VM TestMachine2k16 and we have its tags as shown below.PS C:\> $vm = Get-AzVM -VMName TestMachine2k16 PS C:\> $vm | Select -ExpandProperty TagsOutputKey          Value ---          ----- Owner       Chirag For Ansible Patching_Day Sunday Application SecretTagWe need to change the Patching_Day from Sunday to Wednesday. We will use the below command.Example$tag = @{Patching_Day='Wednesday'} Update-AzTag -Tag $tag -ResourceId $vm.Id -Operation Merge -VerboseOutputName           Value ============ ... Read More

Get Applied Azure Resource Tags Using PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 07:57:16

2K+ Views

To get all the applied tags to the Azure resources we need to use the Get-AZTag command and need to provide ResourceID to it. For example, We need to retrieve the Azure VM tags and we will use its resource ID.PS C:\> $vm = Get-AzVM -Name Testmachine2k16 PS C:\> Get-AzTag -ResourceId $vm.IdYou can see the output in the properties window. Another simple method is to use the Tags property for that particular cmdlet. For example, Get-AzVM, Get-AZResourceGroup, etc use the tag property for displaying the applied tags.PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags Key         ... Read More

Apply a Tag to Azure Resource Group Using PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 07:54:56

698 Views

Like Azure VM, we can apply the azure tags to the resource group or any other resources. The tagging works on the resource ID and in azure, all the resources come with the resource ID property.To apply the tag to the azure resource group, we first need to use get the resource group details to use its resource ID. The below code shows that how we can apply the new tag to the azure resource group.ExamplePS C:\> $rg = Get-AzResourceGroup -Name AnsibleTestRG PS C:\> $tag = @{Owner='Chirag'; CostCenter='USFinance'} PS C:\> New-AZTag -ResourceId $rg.ResourceId -Tag $tag -VerboseOutput

Difference Between New-AzTag and Update-AzTag Command in Azure PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 07:53:31

531 Views

New-AZTagWhen we use the New-AZTag command, it removes all the tags from the particular resource and adds a new tag. This command is generally helpful when we are creating a new resource and we want to apply the tag for it.Update-AZTagWhen we use the Update-AZTag command, it updates, deletes, and replaces the Azure tags. We need to make sure that when we are applying the tag to any existing resource which is already tagged, the Update-AZTag command should be used otherwise New-AZTag command will remove all the previous applied tags and it will add new tags.

Check Element Clickability in Selenium WebDriver

Debomita Bhattacharjee
Updated on 06-Apr-2021 07:52:00

21K+ Views

We can check if the element is clickable or not in Selenium webdriver using synchronization. In synchronization, there is an explicit wait where the driver waits till an expected condition for an element is met.To verify, if the element can be clicked, we shall use the elementToBeClickable condition. A timeout exception is thrown if the criteria for the element is not satisfied till the driver wait time.SyntaxWebDriverWait wt = new WebDriverWait(driver, 5); wt.until(ExpectedConditions.elementToBeClickable (By.className("s-buy")));We have to add - import org.openqa.selenium.support.ui.ExpectedConditions and import org.openqa.selenium.support.ui.WebDriverWait statements to implement ExpectedConditions in our code.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import ... Read More

Delete Specific Tag of Azure VM Using PowerShell

Chirag Nagrekar
Updated on 06-Apr-2021 07:51:36

2K+ Views

To delete the specific tag of the Azure VM, we can use the Delete property of the Operation parameter in the Update-AZTag command. In the below example, we have the below tags of the Azure VM TestMachine2k12.Key             Value ---             ----- Patching_Day    Sunday Owner           ChiragWe need to delete the Patching_Day tag and for that, we also need its value. The below command will delete the specified tag from the Azure VM.PS C:\> $vm = Get-AzVM -VMName TestMachine2k12 PS C:\> $tag = @{'Patching_Day'='Sunday'} PS ... Read More

Advertisements