Maybe driver issue? Please Help :)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Maybe driver issue? Please Help :)

tommy c
Hey all,

I wanted to make a script that could populate a dynamic entry label from a textFile.

This is what I am using:
Windows 10:   64bit
PyCharm:        2018.1.4 (community V)
chrome driver: 2.4.0
chrome:           67.0.3396.99
Selenium:        3.13.0
pip:                  9.0.3


I am running to an issue where my forLoop is not happy about populating the Label fields. I don't know if it is my logic that is bad or the driver crapping out. I looked at the logic over and over again ... it is pretty simple ... maybe that is why I can't see the mistake?


==============
Code
==============
from selenium import webdriver
import time

from selenium.webdriver.chrome.webdriver import WebDriver

driver = webdriver.Chrome("C:\Users\GP\PycharmProjects\CostcoTest\drivers\chromedriver.exe") # type: WebDriver
driver.set_page_load_timeout("30")
driver.get("https://www.costco.com/OrderByItemsDisplayView")
driver.find_element_by_id("itemNumber").send_keys("1111111")

text_file = open("costcoSku.txt", "r")
lines = text_file.readlines()
number = 0

for line in lines:
number += 1
itemField = "itemNumber_" + str(number)
driver.find_element_by_id(itemField).send_keys(line)
text_file.close()

time.sleep(4)
# driver.quit()

================
Execution Errors
================
Traceback (most recent call last):
  File "C:/Users/GP/PycharmProjects/CostcoTest/Test/TestSku.py", line 18, in <module>
    driver.find_element_by_id(itemField).send_keys(line)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element
    'value': value})['value']
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"itemNumber_2"}



Any help will be greatly appreciated :) :)


Thanks!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/68dfd627-d370-4aed-9914-772350baf285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Maybe driver issue? Please Help :)

tommy c
Also, as a side note ... it works fine if you do a manual input, i.e ...

driver.find_element_by_id("itemNumber").send_keys("1111111")
driver.find_element_by_id("itemNumber_1").send_keys("1111112")
driver.find_element_by_id("itemNumber_2").send_keys("1111113")
driver.find_element_by_id("itemNumber_3").send_keys("11111114")

On Wednesday, June 27, 2018 at 9:34:01 AM UTC-4, TomC wrote:
Hey all,

I wanted to make a script that could populate a dynamic entry label from a textFile.

This is what I am using:
Windows 10:   64bit
PyCharm:        2018.1.4 (community V)
chrome driver: 2.4.0
chrome:           67.0.3396.99
Selenium:        3.13.0
pip:                  9.0.3


I am running to an issue where my forLoop is not happy about populating the Label fields. I don't know if it is my logic that is bad or the driver crapping out. I looked at the logic over and over again ... it is pretty simple ... maybe that is why I can't see the mistake?


==============
Code
==============
from selenium import webdriver
import time

from selenium.webdriver.chrome.webdriver import WebDriver

driver = webdriver.Chrome("C:\Users\GP\PycharmProjects\CostcoTest\drivers\chromedriver.exe") # type: WebDriver
driver.set_page_load_timeout("30")
driver.get("<a href="https://www.costco.com/OrderByItemsDisplayView" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;">https://www.costco.com/OrderByItemsDisplayView")
driver.find_element_by_id("itemNumber").send_keys("1111111")

text_file = open("costcoSku.txt", "r")
lines = text_file.readlines()
number = 0

for line in lines:
number += 1
itemField = "itemNumber_" + str(number)
driver.find_element_by_id(itemField).send_keys(line)
text_file.close()

time.sleep(4)
# driver.quit()

================
Execution Errors
================
Traceback (most recent call last):
  File "C:/Users/GP/PycharmProjects/CostcoTest/Test/TestSku.py", line 18, in <module>
    driver.find_element_by_id(itemField).send_keys(line)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element
    'value': value})['value']
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"itemNumber_2"}



Any help will be greatly appreciated :) :)


Thanks!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7cfbc2d8-0807-474a-abfe-780b7f7f65a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Maybe driver issue? Please Help :)

JC Y


On Wednesday, June 27, 2018 at 11:41:16 AM UTC-4, TomC wrote:
Also, as a side note ... it works fine if you do a manual input, i.e ...

driver.find_element_by_id("itemNumber").send_keys("1111111")
driver.find_element_by_id("itemNumber_1").send_keys("1111112")
driver.find_element_by_id("itemNumber_2").send_keys("1111113")
driver.find_element_by_id("itemNumber_3").send_keys("11111114")

On Wednesday, June 27, 2018 at 9:34:01 AM UTC-4, TomC wrote:
Hey all,

I wanted to make a script that could populate a dynamic entry label from a textFile.

This is what I am using:
Windows 10:   64bit
PyCharm:        2018.1.4 (community V)
chrome driver: 2.4.0
chrome:           67.0.3396.99
Selenium:        3.13.0
pip:                  9.0.3


I am running to an issue where my forLoop is not happy about populating the Label fields. I don't know if it is my logic that is bad or the driver crapping out. I looked at the logic over and over again ... it is pretty simple ... maybe that is why I can't see the mistake?


==============
Code
==============
from selenium import webdriver
import time

from selenium.webdriver.chrome.webdriver import WebDriver

driver = webdriver.Chrome("C:\Users\GP\PycharmProjects\CostcoTest\drivers\chromedriver.exe") # type: WebDriver
driver.set_page_load_timeout("30")
driver.get("<a href="https://www.costco.com/OrderByItemsDisplayView" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;">https://www.costco.com/OrderByItemsDisplayView")
driver.find_element_by_id("itemNumber").send_keys("1111111")

text_file = open("costcoSku.txt", "r")
lines = text_file.readlines()
number = 0

for line in lines:
number += 1
itemField = "itemNumber_" + str(number)
driver.find_element_by_id(itemField).send_keys(line)
text_file.close()

time.sleep(4)
# driver.quit()

================
Execution Errors
================
Traceback (most recent call last):
  File "C:/Users/GP/PycharmProjects/CostcoTest/Test/TestSku.py", line 18, in <module>
    driver.find_element_by_id(itemField).send_keys(line)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element
    'value': value})['value']
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"itemNumber_2"}



Any help will be greatly appreciated :) :)


Thanks!


Can you confirm the variable line for each iteration of the for loop prints "1111111", "1111112", etc?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/97854f39-d292-4a79-bf66-b4e0dda6c99f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Maybe driver issue? Please Help :)

tommy c
In reply to this post by tommy c
Never mind, the issue was reading the lines with extra "\n". Strip all and you are good to go.

Thanks.

On Wednesday, June 27, 2018 at 9:34:01 AM UTC-4, TomC wrote:
Hey all,

I wanted to make a script that could populate a dynamic entry label from a textFile.

This is what I am using:
Windows 10:   64bit
PyCharm:        2018.1.4 (community V)
chrome driver: 2.4.0
chrome:           67.0.3396.99
Selenium:        3.13.0
pip:                  9.0.3


I am running to an issue where my forLoop is not happy about populating the Label fields. I don't know if it is my logic that is bad or the driver crapping out. I looked at the logic over and over again ... it is pretty simple ... maybe that is why I can't see the mistake?


==============
Code
==============
from selenium import webdriver
import time

from selenium.webdriver.chrome.webdriver import WebDriver

driver = webdriver.Chrome("C:\Users\GP\PycharmProjects\CostcoTest\drivers\chromedriver.exe") # type: WebDriver
driver.set_page_load_timeout("30")
driver.get("<a href="https://www.costco.com/OrderByItemsDisplayView" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.costco.com%2FOrderByItemsDisplayView\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpGdT8VCd1vEB9X0-NE6ygz9-Riw&#39;;return true;">https://www.costco.com/OrderByItemsDisplayView")
driver.find_element_by_id("itemNumber").send_keys("1111111")

text_file = open("costcoSku.txt", "r")
lines = text_file.readlines()
number = 0

for line in lines:
number += 1
itemField = "itemNumber_" + str(number)
driver.find_element_by_id(itemField).send_keys(line)
text_file.close()

time.sleep(4)
# driver.quit()

================
Execution Errors
================
Traceback (most recent call last):
  File "C:/Users/GP/PycharmProjects/CostcoTest/Test/TestSku.py", line 18, in <module>
    driver.find_element_by_id(itemField).send_keys(line)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element
    'value': value})['value']
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\GP\PycharmProjects\CostcoTest\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"itemNumber_2"}



Any help will be greatly appreciated :) :)


Thanks!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f6556675-ea20-4eca-a407-db83455c07a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.