How can I automate clicking and choosing from dropdown menu and saving? - selenium

There is a database of students about 200, I need to choose 2 items from dropdown and click on save button at the end.
Doing manually takes about 5-6 sec. I want to know if it's possible to automate it?
Screenshots below:
Then choosing 2 items:
Finally hit "save"button:

In selenium you could do it like this:
WebElement mySelectElement = driver.findElement(By.id("id of the dropdown"));
Select dropdown= new Select(mySelectElement);
dropdown.selectByIndex(2);//select it by index
driver.findElement(By.id("id of your button")).click();

Related

Cannot select item from Drop down selenium WITHOUT select

I am new to Python and trying to figure out how to call an item from the drop down list. I managed to make it visible with this code.
price_point = driver.find_elements_by_class_name("chosen-single")
price_point[0].click()
I cannot use Select.
The list is open and visible now But I am not able to click the items inside the list. Any ideas?
Your help is much appreciate!
Access the list item directly and click on it. Here is the sample
driver.find_element_by_xpath("//select[#class='chosen-single']//option[normalize-space(.)='here goes your list item text']").click()
if you have more than one list boxes with class "chosen-single" then use the below to select the item from first list box.
driver.find_element_by_xpath("(//select[#class='chosen-single'])[1]//option[normalize-space(.)='here goes your list item text']").click()

Data-driven dropdown menu Katalon Automation Recorder

I'm trying to automate click with Selenium IDE. I was trying to figure out if I can use the "Select" command, but it didn't work.
I would like to click on the value on the dropdown that I put in my CSV file. Like I want a specific value of the dropdown for each line of my CS.
Here's the code.
Katalon [WebUI] Select is meant only to select default html select component. Yours is custom select box.
You need to select that exactly same way as you do manually like
Click the menu
Wait for dropdown to be visible
Select the particular value based on name from your csv
Based on your html, your Katalon script will be like this,
TestObject menu = new TestObject('Menu').addProperty('css', ConditionType.EQUALS, "div.md-select-menu-container")
WebUI.click(menu)
TestObject dropdownValue = new TestObject('DropDownValue').addProperty('xpath', ConditionType.EQUALS, "//md-option[contains(text(), 'AVAN - Advancè')]")
WebUI.waitForElementVisible(dropdownValue, 30)
WebUI.click(dropdownValue)

Unable to Click on Edit Button , in WebTable

I am using xpath to click on edit button , but i dont know where the webtable starts so i can click on the webelement.
Below is the link for WebTable.
http://demo.automationtesting.in/WebTable.html
Thanks in Advance.
Try this:
// gets the first edit button
WebElement Edit_btn= driver.findElements(By.xpath("//div[#class = 'avddbl']/button")).get(0);
Actions action = new Actions(driver).doubleClick(Edit_btn);
action.build().perform();
If you want some specific selection e.g. want to edit info of particular user
Then you can use below xpath where you have to changes email address only it will click on the edit icon of that particular record .
//div[text()='steven#hotm.com']/../following-sibling::div//div[#class='avddbl']/button[contains(#class,'btn')]

Tosca: How to scan Dropdown textbox which disapper upon opening xScan

I have a problem in scanning a drop-down menu which disappears upon opening the xScan. I need to get the module id of the dropdown menu to verify some test steps.
Do you have any solution with this if it is not really possible to get the module id of the dropdown menu?
Open developer tools in your browser of choice (F12), navigate to the console and input the following code:
var fulldoc='';
var scrollX=0;
var scrollY=0;
document.addEventListener("keydown",function(event){
if(event.key=='q' && event.altKey){
fulldoc=document.body.outerHTML;
scrollY=window.pageYOffset;
scrollX=window.pageXOffset;
}
if(event.key=='w' && event.altKey){
document.body.outerHTML=fulldoc;
document.body.scrollTo(scrollX,scrollY);
}
});
When the window looks the way you would want to scan, press 'Alt + Q', then press 'Alt + W'.
Now your window will freeze and then you can scan your page.
To steer the objects you need to refresh your browser.
You can resolve the issue with below 2 steps
1 - Add some text in textbox which will populate the dropdown below it .
2 - Use Send Keys Module to scroll down and select the value.
I had a similar issue where we had a popup that only appeared when clicking on a text box. The solution we received from the Tricentis trainer was as follows:
Part One
1. Open your application in Chrome
2. Right click the inspect
3. In the inspector window, on the Elements tab, navigate to your html element where it should be (you can do that by clicking on the element and check that you can see the html in the element)
4. Use the debugger to add a break point there, this should pause it and you should be able to see the elements you need to steer it.
5. Once you found the element, you will need the type of element (e.g. div, span, etc), and the class name
Part two
1. Rescan your module and select any element that matches the criteria of your element selected in Part One #5
2. Identify it by only it's class name property and tag
3. Save and close
4. Edit the element in the module view by changing the class name. This should help you steer it
Note: if the element class name is not unique, you might need to use Explicit name.
Good luck

Unable to right click and select a value using Selenium Webdriver

I need to right click using selenium webdriver. When I right click on the date highlighted in red,I will have a menu opened from where I have to select "Show CTR Impressions Label".
I am able to right click and select "Show Impressions Label" but unable to click it.
Here is my code:
string xpath = "//div[#class='highcharts-axis-labels highcharts-xaxis-labels']/span[2]/div";
WebElement element=driver.findElement(By.xpath(xpath));
System.out.println("date="+element.getText());
Actions action= new Actions(driver);
action.moveToElement(element).contextClick(element).build().perform();
action
.sendKeys(Keys.ARROW_DOWN)
.sendKeys(Keys.ARROW_RIGHT)
.sendKeys(Keys.ENTER)
.build().perform();
Kindly suggest.Also, how can I select "Show Impressions Label" based on the text and not the arrow keys?
Any help will be appreciated.
Possible Solution Only , Based on my previous observations :: You are doing it in 2 lines. Combine this and you should be able to do so. Second perform takes focus away from element. And thus the continuity is broken.
action.moveToElement(element).contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_RIGHT).sendKeys(Keys.ENTER).build().perform();