how to handle span class drowpdown in selenium webdriver - selenium

I am not able to click and select the value from dropdown by using XPath
driver.findElement(By.xpath(".//*[#id='ProcessTypeIGCombo']/span")).click();
MY HTML code is as below:
<input class="ui-igcombo-field ui-corner-all" readonly="" style="float: left; display: block; position: absolute; height: 20px; width: 99.7921%;">
for more details please use the screenshots

Related

How do I follow a link through an image without having a link in the div?

The problem is that I can't figure out how to follow a link. The link goes to the page I want when I click on the image, and the desired page opens in a new tab. It's difficult to describe, it's easier to understand from the attached code
<div class="css-1owz1l2">
<span class=" lazy-load-image-background blur lazy-load-image-loaded" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border-radius: 4px; cursor: pointer; object-fit: cover; display: flex;">
<img style="height: 100%; width: 100%; object-fit: cover; border-radius: 4px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;" src="https://public.nftstatic.com/static/nft/zipped/9082041d35194edd87f9078dc9440f7b_zipped.jpeg" sx="[object Object]">
</span>
</div>
You can extract the link from src attribute of img element as following.
In case "css-1owz1l2" class is unique you can do this:
img = driver.find_element_by_xpath("//div[#class='css-1owz1l2']//img")
link = img.get_attribute("src")
Now you can use this link like this:
driver.get(link)
Or by any other way
You can trying catching the image element and clicking on it directly:
# catching the image element
image = driver.find_element_by_xpath("//div[#class='css-1owz1l2']//img")
image.click()

Not able to click a value in Input drop down

I have a strange problem . I have a non select drop down with Id as below . There is a no select tag I can see in the code for this field just an input tag nor I can see the text contained in the drop down in the DOM after a select a value . StaffSoCategory is the text box , SelectStaffSoCategory is the icon for the drop down down arrow and StaffSoCategoryValue I believe is for the values displayed .
<input type="text" id="StaffSoCategory" style="width: 126px; font-weight: lighter; border: 1px solid gray; height: 25px; float: left; font-size: 12px; color: black; font-family: Arial; background-color: white;" readonly="readonly" class="ui-autocomplete-input" autocomplete="off" disabled="disabled">
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">4 results are available, use up and down arrow keys to navigate.</span>
<div id="SelectStaffSoCategory" tabindex="0" style="border-style: solid; border-width: 1px 1px 1px 0px; border-color: gray; width: 22px; height: 29px; background-position: center; cursor: pointer; background-image: url('Images/dropdown.png'); background-repeat: no-repeat; float: left; margin-left: 0px; "></div>
***<input id="StaffSoCategoryValue" type="hidden" value="">***
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" id="ui-id-4" tabindex="0" aria-disabled="false" style="z-index: 1; display: none; top: 584px; left: 829px; width: 148px;"></ul>
Once I select the first drop down value (the visible text in drop down is "Confirmed") then value comes in tag but not the visible text of the value that I see , something like below
<input id="StaffSoCategoryValue" type="hidden" value="BCK-Yes">
Is there a way to click on the first value in the drop down I tried with this value "BCK-Yes" and it said element is not visible. I tried selecting the input by Id and then trying Keys down and keys enter that also didn't work.
The code I am trying is
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement revenuePotential = driver.findElement(By.id("SelectStaffSoCategory")); revenuePotential.click();
WebElement revenuePotentialValue = driver.findElement(By.id("StaffSoCategoryValue"));
js.executeScript("arguments[0].click();", revenuePotentialValue);
Console errors I am getting are
StaffSoJsFun.js?v=2019020100000:1 Uncaught TypeError: $(...).autocomplete is not a function
at HTMLDivElement.<anonymous> (StaffSoJsFun.js?v=2019020100000:1)
at HTMLDivElement.dispatch (jquery-2.0.0.js?v=2019020100000:25)
at HTMLDivElement.y.handle (jquery-2.0.0.js?v=2019020100000:25)
(anonymous) # StaffSoJsFun.js?v=2019020100000:1
dispatch # jquery-2.0.0.js?v=2019020100000:25
y.handle # jquery-2.0.0.js?v=2019020100000:25
Access to XMLHttpRequest at '' from origin 'xx.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Well, the input is hidden, so I'm not surprised selenium tells you the element is not visible. Methods that emulate user actions like click() and sendKeys will not be able to affect hidden elements. However, I think the following might work:
First store that element in an object, let's say element and then try the following code to click on that hidden element:
WebDriver driver= new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get(desiredURL);
//do all the stuff you want to do before `executeScript()`
js.executeScript("arguments[0].click();", element);
Give that a shot?

How to Handle Date field in selenium webdriver?

I need to select a date say like Year as 1947, Month as Aug and Date like 15.
What are the methods and classes that I need to use? I tried using WebElement by xpath. I cant locate the year and month only date is located. Please suggest me the rigt way
This is HTML Page source for that particular element
<td>
<div>
<div class="dais_gwt_input_div" style="margin-left: 140px; margin-bottom: 0px; width: 175px; height: 24px;">
<input id="EMPLOYEE_New_DOB" class="dais_gwt_input_Field" type="text" style="border-style: none; padding: 2px 20px 2px 6px;" maxlength="10"/>
<div id="dais_gwt_fieldcontainer_left_right_top_bottom_label" class="default-label" style="margin-top: 3px; float: left; width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; margin-left: -275px;">DOB</div>
<div id="undefined" class="dais_gwt_image_div" align="center" style="float: right; margin-top: -23px;">
<img id="undefined" class="applyclicks" align="middle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABkUlEQVR42p2Ty07CUBCG+waSGHAnPIbII4hAYSFySaSWxMJClqxISIQIigKPIwkhUsJlSSAQsFx8BC5bfk9HhaJpQjrJpPlm2j//mTPloIlut4t0Or3HqVRKt68Gt9ls0Gg0UKvVUCy+wufzolqtol5/Z/wCl+uSet+861cqb5jPP8ElEvfwenlEIjfgeQ8cjnMIQoSS592w2880vOuHwyEEgwFwJycWtFotsiPLMmIxaWtPlusQRUHD+31RvAVntZ5uBZbLJbM1376wWq0Yz/7wri9Jd+BsNiuazSaMxD+Bfr9P88hmM8T5fJ7OrSgKJpMJG6iTaroCg8EAoVAQhcITcalUokHNZlNKv/+KaroCi8UCnU4Ho9GIeDweE6/Xa8p2u001XQH1abGYmYsAsXpdZvMxLZCaJtMRqwlGHKw0Dj70BYbDATuzOoNn4nL5dwYzTKcHzKDX68HjcSOTeSDO5XKMXT+3oMDpvGC1x30B7SIZ2gN1ldWzGYloVASXTCYRCFwjHo+R4mEp0cfqv/AFv/QghO2HDIwAAAAASUVORK5CYII=" style="cursor: pointer;"/>
</div>
</div>
</div>
</td>
All I need to know is how to locate and access the year and month I tried using arrow keys in it by using xpath and Action class but I cannot click every time and move forward and backward, same with the month. I dont have any idea about how to handle this. I have never faced this before.

Not able to click on the fields inside the left panel of the page

I have tried below code to click on the fields but getting errors as
"org.openqa.selenium.WeddriverException:unknown error: Element is not clickable at point(138,353). Other element would receive the the click… display: block;>…."
Code:
WebElement el1 = driver.findElement(By.xapth(".//*#id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", el1);
UI:
Refer Attached Screenshot
HTML code:
<div id="datatab" class="dijitContentPane panel-content dijitStackContainer-child dijitStackContainer-dijitContentPane" style="padding: 0px; overflow: hidden; left: 0px; top: 0px; height: 154px; width: 258px;" selected="true" data-dojo-type="dijit.layout.ContentPane" widgetid="datatab" title="">
<div id="datatabpanel" class="tabpanel" style="height: 100%; overflow:hidden; padding: 0px">
<div class="section-header-outer">
<div id="fieldlistContainer" style="height: 0px;">
<div id="fieldlist" class="dojoDndSource dojoDndContainer" data-dojo-attach-point="containerNode" widgetid="fieldlist">
<div id="category11545">
<div id="field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" class="category11545 field treenode-leaf-label pentaho-listitem dojoDndItem" fieldid="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" title="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID">Patient ID</div>
You are not allowed to click on the div element, rather you can use a workaround to trigger click event by performing "dragAndDrop operation on the same element".
Try below code:
new WebDriverWait(driver, 10).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[#style='position: absolute; left: 0px; top: 88px; width: 1366px; height: 677px; display: block;']")));
WebElement el1 = driver.findElement(By.xpath(".//*[#id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", el1);
The html you have attached is do not have id attribute with value = BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID. can you just change your xpath from -
WebElement el1 = driver.findElement(By.xapth(".//*#id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
To
WebElement el1 = driver.findElement(By.xapth(".//*[#fieldid='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
//or
WebElement el1 = driver.findElement(By.xapth(".//*[#id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));

How to select/click cursors/icon on a map. Selenium IDE

I am facing a problem with selenium IDE
I want to select/click any 2 cursors on map page
I can't use the id's because every time you refresh the map you will get another different cursors with different id's, till now i was able to select/click only one cursor on map and I can't select another different one
I used
|clickAt | //map/area/ | |
&
|clickAt | //map/area/ | |
to click at one cursor
so please help me to be able to click another
All cursor details:
map id="gmimap208" name="gmimap208">
<area log="miw" coords="11,0,12,1,13,2,14,3,14,4,14,5,14,6,14,7,14,8,14,9,14,10,13,11,12,12,12,13,11,14,10,15,10,16,9,17,9,18,8,19,7,20,7,20,7,19,6,18,6,17,5,16,4,15,4,14,3,13,2,12,2,11,1,10,1,9,0,8,0,7,0,6,0,5,1,4,1,3,2,2,2,1,4,0,11,0" shape="poly" title="" style="cursor: pointer;">
</map>
<div class="gmnoprint" style="width: 15px; height: 21px; overflow: hidden; position: absolute; opacity: 0.01; left: 373px; top: 370px; z-index: 2000;">
<img style="position: absolute; left: 0px; top: 0px; width: 15px; height: 21px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px;" src="/img/property_icons/free/normal.png" draggable="false" usemap="#gmimap226">
<map id="gmimap226" name="gmimap226">
a cursor XPath :
/html/body/div[5]/div[2]/table/tbody/tr/td[2]/div[3]/div[2]/div/div/div[3]/div[2]/div[50]/map/area
a cursor CSS :
html.win body.rtl div.content-for-layout div#page-container table tbody tr td div#Map div div div div div div.gmnoprint map#gmimap83 area
a cursor HTML :
<area log="miw" coords="11,0,12,1,13,2,14,3,14,4,14,5,14,6,14,7,14,8,14,9,14,10,13,11,12,12,12,13,11,14,10,15,10,16,9,17,9,18,8,19,7,20,7,20,7,19,6,18,6,17,5,16,4,15,4,14,3,13,2,12,2,11,1,10,1,9,0,8,0,7,0,6,0,5,1,4,1,3,2,2,2,1,4,0,11,0" shape="poly" title="" style="cursor: pointer;">
Thanks in Advance. :)
You are clicking at the first element twice.
You can specify which element to click on:
//map/area[1]
//map/area[2]
Should get you the first two.