Autocomplete seleniumHow do you disable browser Autocomplete on web form field / input tag?jQuery autocomplete tagging plug-in like StackOverflow's input tags?Removing input background colour for Chrome autocomplete?How to take screenshot with Selenium WebDriverGet HTML Source of WebElement in Selenium WebDriver using PythonNot able to click on the drop down elementUnable to print the Text associated with the li taghow to select the dropdown valueNot able to click on link obtain using findElements methodI am trying to hit on next button in gmail login screen without entering email id , this is basically to test negative scenario

Does Doodling or Improvising on the Piano Have Any Benefits?

How to preserve electronics (computers, iPads and phones) for hundreds of years

What is Cash Advance APR?

When were female captains banned from Starfleet?

Is there a nicer/politer/more positive alternative for "negates"?

Microchip documentation does not label CAN buss pins on micro controller pinout diagram

Giving feedback to someone without sounding prejudiced

How to draw a matrix with arrows in limited space

Is there a RAID 0 Equivalent for RAM?

How can ping know if my host is down

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Stack Interview Code methods made from class Node and Smart Pointers

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Delete multiple columns using awk or sed

Does the Linux kernel need a file system to run?

C++ copy constructor called at return

awk assign to multiple variables at once

How does electrical safety system work on ISS?

Make a Bowl of Alphabet Soup

The IT department bottlenecks progress, how should I handle this?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

Is this toilet slogan correct usage of the English language?

Which was the first story featuring espers?

The Digit Triangles



Autocomplete selenium


How do you disable browser Autocomplete on web form field / input tag?jQuery autocomplete tagging plug-in like StackOverflow's input tags?Removing input background colour for Chrome autocomplete?How to take screenshot with Selenium WebDriverGet HTML Source of WebElement in Selenium WebDriver using PythonNot able to click on the drop down elementUnable to print the Text associated with the li taghow to select the dropdown valueNot able to click on link obtain using findElements methodI am trying to hit on next button in gmail login screen without entering email id , this is basically to test negative scenario













0















I have the list which has multiple links under each section. Each section has different inks I need to click a particular link under each section. I have written the below code but when it executes it gives me: stale element reference: element is not attached to the page document.



driver.findElement(By.xpath("//*[@id="s2id_CountryId"]/a")).click();
List<WebElement> link2 = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link2.size(); i++)
if (link2.get(i).getText().equalsIgnoreCase("ALGERIA"))
link2.get(i).click();



driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"s2id_GlobalId\"]/a")).click();
List<WebElement> link = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link.size(); i++)
if (link.get(i).getText().equalsIgnoreCase("BNZ (Global)"))
link.get(i).click();











share|improve this question









New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What line throws that error? Also, post the relevant HTML in your question.

    – JeffC
    14 hours ago















0















I have the list which has multiple links under each section. Each section has different inks I need to click a particular link under each section. I have written the below code but when it executes it gives me: stale element reference: element is not attached to the page document.



driver.findElement(By.xpath("//*[@id="s2id_CountryId"]/a")).click();
List<WebElement> link2 = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link2.size(); i++)
if (link2.get(i).getText().equalsIgnoreCase("ALGERIA"))
link2.get(i).click();



driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"s2id_GlobalId\"]/a")).click();
List<WebElement> link = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link.size(); i++)
if (link.get(i).getText().equalsIgnoreCase("BNZ (Global)"))
link.get(i).click();











share|improve this question









New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What line throws that error? Also, post the relevant HTML in your question.

    – JeffC
    14 hours ago













0












0








0








I have the list which has multiple links under each section. Each section has different inks I need to click a particular link under each section. I have written the below code but when it executes it gives me: stale element reference: element is not attached to the page document.



driver.findElement(By.xpath("//*[@id="s2id_CountryId"]/a")).click();
List<WebElement> link2 = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link2.size(); i++)
if (link2.get(i).getText().equalsIgnoreCase("ALGERIA"))
link2.get(i).click();



driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"s2id_GlobalId\"]/a")).click();
List<WebElement> link = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link.size(); i++)
if (link.get(i).getText().equalsIgnoreCase("BNZ (Global)"))
link.get(i).click();











share|improve this question









New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have the list which has multiple links under each section. Each section has different inks I need to click a particular link under each section. I have written the below code but when it executes it gives me: stale element reference: element is not attached to the page document.



driver.findElement(By.xpath("//*[@id="s2id_CountryId"]/a")).click();
List<WebElement> link2 = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link2.size(); i++)
if (link2.get(i).getText().equalsIgnoreCase("ALGERIA"))
link2.get(i).click();



driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"s2id_GlobalId\"]/a")).click();
List<WebElement> link = driver.findElements(By.xpath("//*[@id="select2-drop"]/ul//li[.]"));

for (int i = 0; i <= link.size(); i++)
if (link.get(i).getText().equalsIgnoreCase("BNZ (Global)"))
link.get(i).click();








java selenium selenium-webdriver autocomplete






share|improve this question









New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 17 hours ago









lelloman

8,79133555




8,79133555






New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 19 hours ago









Gnanapriya GGnanapriya G

1




1




New contributor




Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Gnanapriya G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • What line throws that error? Also, post the relevant HTML in your question.

    – JeffC
    14 hours ago

















  • What line throws that error? Also, post the relevant HTML in your question.

    – JeffC
    14 hours ago
















What line throws that error? Also, post the relevant HTML in your question.

– JeffC
14 hours ago





What line throws that error? Also, post the relevant HTML in your question.

– JeffC
14 hours ago












1 Answer
1






active

oldest

votes


















0














you can use:



 List<WebElement> listOfLinks = driver.findElements(By.xpath("yourXpath"));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase("your text"))
link.click();

);


forEach will get each link from your list and it will do with each whatever you have between those brackets. In this case, the if condition.



For the second part you can also use foreach. You can also put waits in for each, so for each link it will wait for a certain time.



If you want to use lambdas, you need java 8.



Edit: after the info you got me, I have managed to write this for you:



public static void main(String[] args) throws InterruptedException 
System.setProperty("webdriver.chrome.driver",".//src//browser//chromedriver.exe");
yourMethodName("xpathExample", "xPathListPathExample", "iWantToFindThis","theTextIWantToComplete");


private static void yourMethodName(String xPathOfTheElement,String xPathListPath, String theTextYouWantToFind, String theTextYouWantToComplete) throws InterruptedException
driver.findElement(By.xpath(xPathOfTheElement)).sendKeys(theTextYouWantToComplete);
Thread.sleep(2000);

List<WebElement> listOfLinks = driver.findElements(By.xpath(xPathListPath));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase(theTextYouWantToFind))
link.click();

);



Hopefully this is clear enough for you.






share|improve this answer










New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

    – Gnanapriya G
    17 hours ago











  • Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

    – Gnanapriya G
    17 hours ago











  • @GnanapriyaG I have edited the text above.

    – ib23
    14 hours ago










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Gnanapriya G is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55277007%2fautocomplete-selenium%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














you can use:



 List<WebElement> listOfLinks = driver.findElements(By.xpath("yourXpath"));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase("your text"))
link.click();

);


forEach will get each link from your list and it will do with each whatever you have between those brackets. In this case, the if condition.



For the second part you can also use foreach. You can also put waits in for each, so for each link it will wait for a certain time.



If you want to use lambdas, you need java 8.



Edit: after the info you got me, I have managed to write this for you:



public static void main(String[] args) throws InterruptedException 
System.setProperty("webdriver.chrome.driver",".//src//browser//chromedriver.exe");
yourMethodName("xpathExample", "xPathListPathExample", "iWantToFindThis","theTextIWantToComplete");


private static void yourMethodName(String xPathOfTheElement,String xPathListPath, String theTextYouWantToFind, String theTextYouWantToComplete) throws InterruptedException
driver.findElement(By.xpath(xPathOfTheElement)).sendKeys(theTextYouWantToComplete);
Thread.sleep(2000);

List<WebElement> listOfLinks = driver.findElements(By.xpath(xPathListPath));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase(theTextYouWantToFind))
link.click();

);



Hopefully this is clear enough for you.






share|improve this answer










New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

    – Gnanapriya G
    17 hours ago











  • Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

    – Gnanapriya G
    17 hours ago











  • @GnanapriyaG I have edited the text above.

    – ib23
    14 hours ago















0














you can use:



 List<WebElement> listOfLinks = driver.findElements(By.xpath("yourXpath"));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase("your text"))
link.click();

);


forEach will get each link from your list and it will do with each whatever you have between those brackets. In this case, the if condition.



For the second part you can also use foreach. You can also put waits in for each, so for each link it will wait for a certain time.



If you want to use lambdas, you need java 8.



Edit: after the info you got me, I have managed to write this for you:



public static void main(String[] args) throws InterruptedException 
System.setProperty("webdriver.chrome.driver",".//src//browser//chromedriver.exe");
yourMethodName("xpathExample", "xPathListPathExample", "iWantToFindThis","theTextIWantToComplete");


private static void yourMethodName(String xPathOfTheElement,String xPathListPath, String theTextYouWantToFind, String theTextYouWantToComplete) throws InterruptedException
driver.findElement(By.xpath(xPathOfTheElement)).sendKeys(theTextYouWantToComplete);
Thread.sleep(2000);

List<WebElement> listOfLinks = driver.findElements(By.xpath(xPathListPath));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase(theTextYouWantToFind))
link.click();

);



Hopefully this is clear enough for you.






share|improve this answer










New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

    – Gnanapriya G
    17 hours ago











  • Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

    – Gnanapriya G
    17 hours ago











  • @GnanapriyaG I have edited the text above.

    – ib23
    14 hours ago













0












0








0







you can use:



 List<WebElement> listOfLinks = driver.findElements(By.xpath("yourXpath"));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase("your text"))
link.click();

);


forEach will get each link from your list and it will do with each whatever you have between those brackets. In this case, the if condition.



For the second part you can also use foreach. You can also put waits in for each, so for each link it will wait for a certain time.



If you want to use lambdas, you need java 8.



Edit: after the info you got me, I have managed to write this for you:



public static void main(String[] args) throws InterruptedException 
System.setProperty("webdriver.chrome.driver",".//src//browser//chromedriver.exe");
yourMethodName("xpathExample", "xPathListPathExample", "iWantToFindThis","theTextIWantToComplete");


private static void yourMethodName(String xPathOfTheElement,String xPathListPath, String theTextYouWantToFind, String theTextYouWantToComplete) throws InterruptedException
driver.findElement(By.xpath(xPathOfTheElement)).sendKeys(theTextYouWantToComplete);
Thread.sleep(2000);

List<WebElement> listOfLinks = driver.findElements(By.xpath(xPathListPath));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase(theTextYouWantToFind))
link.click();

);



Hopefully this is clear enough for you.






share|improve this answer










New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










you can use:



 List<WebElement> listOfLinks = driver.findElements(By.xpath("yourXpath"));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase("your text"))
link.click();

);


forEach will get each link from your list and it will do with each whatever you have between those brackets. In this case, the if condition.



For the second part you can also use foreach. You can also put waits in for each, so for each link it will wait for a certain time.



If you want to use lambdas, you need java 8.



Edit: after the info you got me, I have managed to write this for you:



public static void main(String[] args) throws InterruptedException 
System.setProperty("webdriver.chrome.driver",".//src//browser//chromedriver.exe");
yourMethodName("xpathExample", "xPathListPathExample", "iWantToFindThis","theTextIWantToComplete");


private static void yourMethodName(String xPathOfTheElement,String xPathListPath, String theTextYouWantToFind, String theTextYouWantToComplete) throws InterruptedException
driver.findElement(By.xpath(xPathOfTheElement)).sendKeys(theTextYouWantToComplete);
Thread.sleep(2000);

List<WebElement> listOfLinks = driver.findElements(By.xpath(xPathListPath));
listOfLinks.forEach(link ->
if (link.getText().equalsIgnoreCase(theTextYouWantToFind))
link.click();

);



Hopefully this is clear enough for you.







share|improve this answer










New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited 14 hours ago





















New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 18 hours ago









ib23ib23

13




13




New contributor




ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ib23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

    – Gnanapriya G
    17 hours ago











  • Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

    – Gnanapriya G
    17 hours ago











  • @GnanapriyaG I have edited the text above.

    – ib23
    14 hours ago

















  • Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

    – Gnanapriya G
    17 hours ago











  • Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

    – Gnanapriya G
    17 hours ago











  • @GnanapriyaG I have edited the text above.

    – ib23
    14 hours ago
















Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

– Gnanapriya G
17 hours ago





Thanks for ur response... I need to know one more thing... how can I call it on run time.. while in case I have to handle two more autocomplete fields on the same page

– Gnanapriya G
17 hours ago













Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

– Gnanapriya G
17 hours ago





Here I have been attached by code .. plz overview that,.. and give me suggestion to made changes..

– Gnanapriya G
17 hours ago













@GnanapriyaG I have edited the text above.

– ib23
14 hours ago





@GnanapriyaG I have edited the text above.

– ib23
14 hours ago












Gnanapriya G is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Gnanapriya G is a new contributor. Be nice, and check out our Code of Conduct.












Gnanapriya G is a new contributor. Be nice, and check out our Code of Conduct.











Gnanapriya G is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55277007%2fautocomplete-selenium%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현