I have below snippet of html code which is created using reactjs and could you please help me out finding xpath for the same? When I try with chromepath it is throwing this error "This is a pseudo element and selectors can't be generated for pseudo element".
Snippet:
Related
When I tried to automate Linkedin with related to automation study research, I found that the drop down clicks are not working.
The code was:
Select dropdown = new Select(driver.findElement(By.xpath(properties.getProperty("VAR_LANUAGEDROPDOWN"))));
dropdown.selectByVisibleText("Português (Portuguese)");
Thread.sleep(4000);
The console is displaying:
no such element: Unable to locate element:
{"method":"name","selector":"selectLanguage"} (Session info:
chrome=63.0.3239.132)
Can any one help me to find what the error is and how can I resolve it?
It seems, that selector of the Dropdown is incorrect. Selenium can't find it. Try to define a correct selector.
If selector is correct, than you need to wait, till this element appears in DOM.
I do not know how to locate the pseudo element ,while using robotframework-selenium2Library to do web test.
Any help is useful.Thanks.
the test script is like below:
Click Element my_element
ID:
Click Element | id=my_element Matches by #id attribute
Thank to Alex Bruce, it works.
Pseudo web elements wont be part of DOM so it is not possible to get attribute value from selenium2library. Instead we can get it from Execute Javascript like below snippet.
${attribute_value}= Execute Javascript return window.getComputedStyle(${element},${pseudo_element}).getPropertyValue('${attribute}');
I was looking for same and found great working code in below link. (JFI - No promo)
Check key "Get Pseudo Element CSS Attribute Value" in the below link.
https://adiralashivaprasad.blogspot.com/2018/06/how-to-get-pseudo-element-css-attribute.html
I am trying to write selenium webDriver code for below HTML Code and it is throwing the error like:
Unable to find element
Can any help on this?
HTML Code :
<input class="_3uUUD5" type="checkbox" is="null" readonly="">
<div class="_1p7h2j" is="null"></div>
<div class="_1GEhLw" is="null">Gionee</div>
I am trying to select the check box for above mentioned HTML Code and please find my code below. I tried:
bothd.findElement(By.xpath("/html/body/div[1]/div/div[2]/div/div[2]/div[2]/div/div[4]/section/div[2]/div/div[1]/div[2]/div[72]/div/div/div/label/div[1]")).click();
or
d.findElement(By.className("_1p7h2j")).click();
If you want to locate checkbox element wrt Gionee text, try using below xpath :-
.//input[following-sibling::div[text()='Gionee'] and #type='checkbox']
i am trying to Automate flipkart website in which i am trying to change address but "add new adress" is not getting clicked i have attached the snapshot
my code is like driver.findElement(By.xpath("//*[#id='ng-app']/div/div[2]/ul/li[2]/div/div[2]/div[2]/div[2]/a/span")).click();
please give the appropriate help
I doesn't look that you are clicking active element, the xpath is //*[#id='ng-app']/div/div[2]/ul/li[2]/div/div[2]/div[2]/div[2]/a/span not correct it clicks on some span.
Use Firepath https://addons.mozilla.org/en-US/firefox/addon/firepath/ to get the xpath.
To ensure that button is clickable Use isDisplayed() and isEnabled() method before clicking on "Add New Address" button, this method return boolean value.
driver.findElement(By.xpath("//*[#id='ng-app']/div/div[2]/ul/li[2]/div/div[2]/div[2]/div[2]/a/span")).isDisplayed();
driver.findElement(By.xpath("//*[#id='ng-app']/div/div[2]/ul/li[2]/div/div[2]/div[2]/div[2]/a/span")).isEnabled();
Also you can verify that element is exist on page or not using below code
if(driver.findElements(byVal).size()!=0){
// Element is present.
}
hope it may helpful to identify cause of issue, why its not clickable.
First and foremost, Use a customized Xpath instead of the one you are using which is extracted directly from the browser. If no customized Xpath can be constructed then try a customized Css or any other locator if possible.
Try to go through the following attempts in order (I hope you can grasp why this is):
1- If .click() still doesn’t work, then keep on changing the values of the attributes you are using to construct your customized xpath, cssSelector, or locator.
2- Use the Actions class.
3- Use JavaScript executioner
4- instead of click(), try using any of: .sendKeys(“\n”). Or .sendKeys(keys.ENTER) or .sendKeys(keys.RETURN)
I'm having trouble trying to click on on a button within a form.
I've tried xpath, cssselector, className, id, but still cannot find it.
Here's the HTML snippet for the button:
<input type="button" value="Continue" id="ni-reg-btn-register" class="btnNext ni-reg-btn-register">
I'm using WebDriver in Java
Getting this trace:
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 30.09 seconds
Frequency: 100%
Browser: Firefox
URL: https://subscription.thetimes.co.uk/webjourney/webj_capturecustomerdetails
I've tried each of the following lines of code one by one (but no luck):
driver.findElement(By.className("btnNext ni-reg-btn-register")).click();
driver.findElement(By.cssSelector("buttons#ni-reg-btn-register.btnNext ni-reg-btn-register")).click();
List<WebElement> buttonlist= driver.findElements(By.className("btnNext ni-reg-btn-register"));
driver.findElement(By.id("ni-reg-btn-register")).click();
driver.findElement(By.xpath("//*[#id="ni-reg-btn-register"]")).click();
I was able to click the Continue Button using the below xpath.
//input[#id='ni-reg-btn-register']
I would suggest trying a WebDriverWait call to wait for the element in question to exist on the page prior to interacting with it. The Java documentation can be found here. It appears that while you are using the correct locator and your page is working, there is a timing issue where Selenium is trying to access the element prior to it being loaded.
EDIT: I was unable to locate an element on the provided page with the supplied id. I assume I am missing a step, but I did a search on the HTML for that page and found nothing.
I dont find the above button on the page link you provided ..
better chk the page link and try to give some wait statement after page load ...
implicit wait would be better or simpli Thread.sleep(2000);